Browse Source

* fixed crashes in asciichar2unicode() and ascii2unicode() in case
the current codepage is utf-8

git-svn-id: trunk@4102 -

Jonas Maebe 19 years ago
parent
commit
d593c10adf
1 changed files with 23 additions and 6 deletions
  1. 23 6
      compiler/widestr.pas

+ 23 - 6
compiler/widestr.pas

@@ -154,8 +154,13 @@ unit widestr;
       var
          m : punicodemap;
       begin
-         m:=getmap(aktsourcecodepage);
-         asciichar2unicode:=getunicode(c,m);
+         if (aktsourcecodepage <> 'utf8') then
+           begin
+             m:=getmap(aktsourcecodepage);
+             asciichar2unicode:=getunicode(c,m);
+           end
+         else
+           result:=tcompilerwidechar(c);
       end;
 
     function unicode2asciichar(c : tcompilerwidechar) : char;
@@ -177,11 +182,23 @@ unit widestr;
          source:=p;
          r^.len:=l;
          dest:=tcompilerwidecharptr(r^.data);
-         for i:=1 to l do
+         if (aktsourcecodepage <> 'utf8') then
+           begin
+             for i:=1 to l do
+                begin
+                  dest^:=getunicode(source^,m);
+                  inc(dest);
+                  inc(source);
+                end;
+           end
+         else
            begin
-              dest^:=getunicode(source^,m);
-              inc(dest);
-              inc(source);
+             for i:=1 to l do
+                begin
+                  dest^:=tcompilerwidechar(source^);
+                  inc(dest);
+                  inc(source);
+                end;
            end;
       end;