View Issue Details

IDProjectCategoryView StatusLast Update
0023446LazarusLazUtilspublic2012-12-14 13:01
ReporterZoran VučenovićAssigned ToFelipe Monteiro de Carvalho 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version1.1 (SVN)Product Build 
Target VersionFixed in Version1.1 (SVN) 
Summary0023446: Unit LConvEncoding - function ConvertEncoding does not work between ucs2 and ansi charsets
DescriptionWhen one of the encodings is double byte (i.e. ucs2le or ucs2be) and the other is anything but utf8, the function does not work and it returns the string which was passed to the function in the first place.

For example, ConvertEncoding(S, 'ucs2le', 'cp1250') does not work.

The patch is attached.
TagsNo tags attached.
Fixed in Revision39536
LazTarget-
Widgetset
Attached Files
  • lconvencoding.pas.diff (1,169 bytes)
    Index: components/lazutils/lconvencoding.pas
    ===================================================================
    --- components/lazutils/lconvencoding.pas	(revision 39472)
    +++ components/lazutils/lconvencoding.pas	(working copy)
    @@ -6527,6 +6527,14 @@
           Result:=KOI8ToUTF8(s);
           Encoded := true;
         end
    +    else if AFrom = EncodingUCS2LE then begin
    +      Result := UCS2LEToUTF8(s);
    +      Encoded := true;
    +    end
    +    else if AFrom = EncodingUCS2BE then begin
    +      Result := UCS2BEToUTF8(s);
    +      Encoded := true;
    +    end
         else if (AFrom=SysEnc) and Assigned(ConvertAnsiToUTF8) then begin
           Result:=ConvertAnsiToUTF8(s);
           Encoded := true;
    @@ -6621,6 +6629,14 @@
             Result:=UTF8ToKOI8(Result);
             Encoded := true;
           end
    +      else if ATo = EncodingUCS2LE then begin
    +        Result := UTF8ToUCS2LE(Result);
    +        Encoded := true;
    +      end
    +      else if ATo = EncodingUCS2BE then begin
    +        Result := UTF8ToUCS2BE(Result);
    +        Encoded := true;
    +      end
           else if (ATo=SysEnc) and Assigned(ConvertUTF8ToAnsi) then begin
             Result:=ConvertUTF8ToAnsi(Result);
             Encoded := true;
    
    lconvencoding.pas.diff (1,169 bytes)

Activities

2012-12-07 14:51

 

lconvencoding.pas.diff (1,169 bytes)
Index: components/lazutils/lconvencoding.pas
===================================================================
--- components/lazutils/lconvencoding.pas	(revision 39472)
+++ components/lazutils/lconvencoding.pas	(working copy)
@@ -6527,6 +6527,14 @@
       Result:=KOI8ToUTF8(s);
       Encoded := true;
     end
+    else if AFrom = EncodingUCS2LE then begin
+      Result := UCS2LEToUTF8(s);
+      Encoded := true;
+    end
+    else if AFrom = EncodingUCS2BE then begin
+      Result := UCS2BEToUTF8(s);
+      Encoded := true;
+    end
     else if (AFrom=SysEnc) and Assigned(ConvertAnsiToUTF8) then begin
       Result:=ConvertAnsiToUTF8(s);
       Encoded := true;
@@ -6621,6 +6629,14 @@
         Result:=UTF8ToKOI8(Result);
         Encoded := true;
       end
+      else if ATo = EncodingUCS2LE then begin
+        Result := UTF8ToUCS2LE(Result);
+        Encoded := true;
+      end
+      else if ATo = EncodingUCS2BE then begin
+        Result := UTF8ToUCS2BE(Result);
+        Encoded := true;
+      end
       else if (ATo=SysEnc) and Assigned(ConvertUTF8ToAnsi) then begin
         Result:=ConvertUTF8ToAnsi(Result);
         Encoded := true;
lconvencoding.pas.diff (1,169 bytes)

Felipe Monteiro de Carvalho

2012-12-14 13:00

developer   ~0064298

Thanks, applied

Issue History

Date Modified Username Field Change
2012-12-07 14:51 Zoran Vučenović New Issue
2012-12-07 14:51 Zoran Vučenović File Added: lconvencoding.pas.diff
2012-12-14 12:59 Felipe Monteiro de Carvalho Status new => assigned
2012-12-14 12:59 Felipe Monteiro de Carvalho Assigned To => Felipe Monteiro de Carvalho
2012-12-14 13:00 Felipe Monteiro de Carvalho Fixed in Revision => 39536
2012-12-14 13:00 Felipe Monteiro de Carvalho LazTarget => -
2012-12-14 13:00 Felipe Monteiro de Carvalho Status assigned => resolved
2012-12-14 13:00 Felipe Monteiro de Carvalho Fixed in Version => 1.1 (SVN)
2012-12-14 13:00 Felipe Monteiro de Carvalho Resolution open => fixed
2012-12-14 13:00 Felipe Monteiro de Carvalho Note Added: 0064298