瀏覽代碼

utf8: system codepage

mattias 11 月之前
父節點
當前提交
25130105d7
共有 3 個文件被更改,包括 20 次插入3 次删除
  1. 2 0
      demo/Combobox/ComboboxNative.lpr
  2. 1 1
      demo/Combobox/DemoCombobox.pas
  3. 17 2
      src/base/utf8utils.pp

+ 2 - 0
demo/Combobox/ComboboxNative.lpr

@@ -1,11 +1,13 @@
 program ComboboxNative;
 
 uses
+  UTF8Utils,
   dl,
   Fresnel, // initializes the widgetset
   Fresnel.App, MainUnit, DemoCombobox;
 
 begin
+  writeln();
   FresnelApplication.HookFresnelLog:=true;
   FresnelApplication.Initialize;
   FresnelApplication.CreateForm(TMainForm,MainForm);

+ 1 - 1
demo/Combobox/DemoCombobox.pas

@@ -196,7 +196,7 @@ begin
   CaptionIcon:=TLabel.Create(Self);
   with CaptionIcon do begin
     Name:='CaptionIcon';
-    Caption:='↧';
+    Caption:=#$E2#$8C#$84; // Down Arrowhead
     CSSClasses.Add('ComboboxCaptionIcon');
     Parent:=CaptionDiv;
   end;

+ 17 - 2
src/base/utf8utils.pp

@@ -22,9 +22,16 @@ unit UTF8Utils;
 {$WARN 6058 off : Call to subroutine "$1" marked as inline is not inlined}
 {$ENDIF}
 
+{$IFNDEF fpc_unicodestrings}
+  {$DEFINE UTF8_RTL}
+{$ENDIF}
+
 interface
 
 uses
+  {$IFDEF Unix}
+  cwstring,
+  {$ENDIF}
   {$ifdef windows}
   Windows,
   {$endif}
@@ -190,8 +197,6 @@ var
 
 implementation
 
-
-
 {$IFDEF WinCE}
 // CP_UTF8 is missing in the windows unit of the Windows CE RTL
 const
@@ -4055,8 +4060,18 @@ begin
     FPUpChars[c]:=UpCase(c);
 end;
 
+procedure InitUTF8;
+begin
+  {$ifdef UTF8_RTL}
+  SetMultiByteConversionCodePage(CP_UTF8);
+  // SetMultiByteFileSystemCodePage(CP_UTF8); not needed, this is the default under Windows
+  SetMultiByteRTLFileSystemCodePage(CP_UTF8);
+  {$ENDIF}
+end;
 
 initialization
   InitFPUpchars;
+  InitUTF8;
+
 end.