Browse Source

* Take into account endianness when emitting resource string data

Michael VAN CANNEYT 2 years ago
parent
commit
d0233e8d07
1 changed files with 9 additions and 1 deletions
  1. 9 1
      compiler/cresstr.pas

+ 9 - 1
compiler/cresstr.pas

@@ -171,6 +171,8 @@ uses
         R : TResourceStringItem;
         R : TResourceStringItem;
         resstrdef: tdef;
         resstrdef: tdef;
         tcb : ttai_typedconstbuilder;
         tcb : ttai_typedconstbuilder;
+        enc : tstringencoding;
+
       begin
       begin
         resstrdef:=search_system_type('TRESOURCESTRINGRECORD').typedef;
         resstrdef:=search_system_type('TRESOURCESTRINGRECORD').typedef;
 
 
@@ -200,7 +202,13 @@ uses
             if (R.len<>0) then
             if (R.len<>0) then
               begin
               begin
               if R.isUnicode and assigned(R.WValue) then
               if R.isUnicode and assigned(R.WValue) then
-                valuelab:=tcb.emit_unicodestring_const(current_asmdata.asmlists[al_const],R.WValue,CP_UTF16,False)
+                begin
+                if target_info.endian=endian_little then
+                  enc:=CP_UTF16
+                else
+                  enc:=CP_UTF16BE;
+                valuelab:=tcb.emit_unicodestring_const(current_asmdata.asmlists[al_const],R.WValue,enc,False);
+                end
               else
               else
                 begin
                 begin
                 if assigned(R.AValue) then
                 if assigned(R.AValue) then