Ver código fonte

* take current value of DefaultSystemCodePage into account in
fpc_unicodestr_to_chararray() for the JVM target

git-svn-id: trunk@33161 -

Jonas Maebe 9 anos atrás
pai
commit
3526fb27a7
1 arquivos alterados com 9 adições e 5 exclusões
  1. 9 5
      rtl/java/justrings.inc

+ 9 - 5
rtl/java/justrings.inc

@@ -18,6 +18,10 @@
 { unicodestring is a plain java.lang.String }
 {$define FPC_UNICODESTRING_TYPE_DEFINED}
 
+{ helpers for converting between Windows and Java code page identifiers }
+
+{$i jwin2javacharset.inc}
+
 {$define FPC_HAS_DEFAULT_UNICODE_2_ANSI_MOVE}
 procedure DefaultUnicode2AnsiMove(source:punicodechar;var dest:RawByteString;cp : TSystemCodePage;len:SizeInt);
 var
@@ -421,12 +425,16 @@ procedure fpc_unicodestr_to_chararray(out res: array of AnsiChar; const src: Uni
 var
   len: longint;
   temp: array of jbyte;
+  csname: unicodestring;
 begin
   len:=length(src);
   { make sure we don't dereference src if it can be nil (JM) }
   if len>0 then
     begin
-      temp:=JLString(src).getBytes;
+      csname:=win2javacs(DefaultSystemCodePage);
+      if csname='<unsupported>' then
+        csname:='US-ASCII';
+      temp:=JLString(src).getBytes(csname);
       len:=length(temp);
       if len>length(res) then
         len:=length(res);
@@ -912,10 +920,6 @@ Begin
 End;
 
 
-{ helpers for converting between Windows and Java code page identifiers }
-
-{$i jwin2javacharset.inc}
-
 { *************************************************************************** }
 { ************************* Collator threadvar ****************************** }
 { *************************************************************************** }