rolling back my PChar stuff, because unC0Rr improves string handling pas2c instead <3
authorsheepluva
Thu, 06 Feb 2014 22:03:53 +0100
changeset 10116 dd27562b6f21
parent 10115 794af9339726
child 10117 f6aa60d8a336
rolling back my PChar stuff, because unC0Rr improves string handling pas2c instead <3
hedgewars/uAmmos.pas
hedgewars/uCaptions.pas
hedgewars/uChat.pas
hedgewars/uGame.pas
hedgewars/uGears.pas
hedgewars/uGearsHedgehog.pas
hedgewars/uGearsUtils.pas
hedgewars/uLocale.pas
hedgewars/uRenderUtils.pas
hedgewars/uStats.pas
hedgewars/uStore.pas
hedgewars/uTeams.pas
hedgewars/uUtils.pas
--- a/hedgewars/uAmmos.pas	Fri Feb 07 00:47:51 2014 +0400
+++ b/hedgewars/uAmmos.pas	Thu Feb 06 22:03:53 2014 +0100
@@ -398,7 +398,7 @@
             s:= s + ' (' + IntToStr(Count) + ')';
         if (Propz and ammoprop_Timerable) <> 0 then
             s:= s + ', ' + IntToStr(Timer div 1000) + ' ' + trammo[sidSeconds];
-        AddCaption(Str2PChar(s), Team^.Clan^.Color, capgrpAmmoinfo);
+        AddCaption(s, Team^.Clan^.Color, capgrpAmmoinfo);
         if (Propz and ammoprop_NeedTarget) <> 0 then
             begin
             if Gear <> nil then Gear^.State:= Gear^.State or      gstHHChooseTarget;
--- a/hedgewars/uCaptions.pas	Fri Feb 07 00:47:51 2014 +0400
+++ b/hedgewars/uCaptions.pas	Thu Feb 06 22:03:53 2014 +0100
@@ -23,7 +23,7 @@
 interface
 uses uTypes;
 
-procedure AddCaption(caption: PChar; Color: Longword; Group: TCapGroup);
+procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup);
 procedure DrawCaptions;
 procedure ReloadCaptions(unload: boolean);
 
@@ -42,11 +42,8 @@
 var
     Captions: array[TCapGroup] of TCaptionStr;
 
-procedure AddCaption(caption: PChar; Color: Longword; Group: TCapGroup);
-var
-    s: shortstring;
+procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup);
 begin
-    s:= caption;
     if cOnlyStats then exit;
     if Length(s) = 0 then
         exit;
--- a/hedgewars/uChat.pas	Fri Feb 07 00:47:51 2014 +0400
+++ b/hedgewars/uChat.pas	Thu Feb 06 22:03:53 2014 +0100
@@ -100,7 +100,7 @@
     delete(str, 1, 1)
     end;
 
-font:= CheckCJKFont(Str2PChar(str), fnt16);
+font:= CheckCJKFont(str, fnt16);
 w:= 0; h:= 0; // avoid compiler hints
 TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(str), @w, @h);
 
--- a/hedgewars/uGame.pas	Fri Feb 07 00:47:51 2014 +0400
+++ b/hedgewars/uGame.pas	Thu Feb 06 22:03:53 2014 +0100
@@ -26,7 +26,7 @@
 ////////////////////
     implementation
 ////////////////////
-uses uUtils, uInputHandler, uTeams, uIO, uAI, uGears, uSound, uLocale, uCaptions,
+uses uInputHandler, uTeams, uIO, uAI, uGears, uSound, uLocale, uCaptions,
      uTypes, uVariables, uCommands, uConsts, uVisualGearsList
      {$IFDEF USE_TOUCH_INTERFACE}, uTouch{$ENDIF};
 
@@ -77,7 +77,7 @@
         else if not isAudioMuted then
             begin
             str(i, s);
-            AddCaption(FormatPChar(trmsg[sidVolume], Str2PChar(s)), cWhiteColor, capgrpVolume)
+            AddCaption(Format(trmsg[sidVolume], s), cWhiteColor, capgrpVolume)
             end
         end;
     end;
--- a/hedgewars/uGears.pas	Fri Feb 07 00:47:51 2014 +0400
+++ b/hedgewars/uGears.pas	Thu Feb 06 22:03:53 2014 +0100
@@ -331,7 +331,7 @@
                     if i = 1 then
                         AddCaption(trmsg[sidRoundSD], cWhiteColor, capgrpGameState)
                     else if (i = 2) or ((i > 0) and ((i mod 50 = 0) or ((i <= 25) and (i mod 5 = 0)))) then
-                        AddCaption(FormatPChar(trmsg[sidRoundsSD], Str2PChar(s)), cWhiteColor, capgrpGameState);
+                        AddCaption(Format(trmsg[sidRoundsSD], s), cWhiteColor, capgrpGameState);
                     end;
                 end;
             if bBetweenTurns
--- a/hedgewars/uGearsHedgehog.pas	Fri Feb 07 00:47:51 2014 +0400
+++ b/hedgewars/uGearsHedgehog.pas	Thu Feb 06 22:03:53 2014 +0100
@@ -185,23 +185,23 @@
         color:= Gear^.Hedgehog^.Team^.Clan^.Color;
         case Gear^.MsgParam of
             1: begin
-               AddCaption(FormatPChar(trmsg[sidBounce], trmsg[sidBounce1]), color, capgrpAmmostate);
+               AddCaption(FormatA(trmsg[sidBounce], trmsg[sidBounce1]), color, capgrpAmmostate);
                CurWeapon^.Bounciness:= 350;
                end;
             2: begin
-               AddCaption(FormatPChar(trmsg[sidBounce], trmsg[sidBounce2]), color, capgrpAmmostate);
+               AddCaption(FormatA(trmsg[sidBounce], trmsg[sidBounce2]), color, capgrpAmmostate);
                CurWeapon^.Bounciness:= 700;
                end;
             3: begin
-               AddCaption(FormatPChar(trmsg[sidBounce], trmsg[sidBounce3]), color, capgrpAmmostate);
+               AddCaption(FormatA(trmsg[sidBounce], trmsg[sidBounce3]), color, capgrpAmmostate);
                CurWeapon^.Bounciness:= 1000;
                end;
             4: begin
-               AddCaption(FormatPChar(trmsg[sidBounce], trmsg[sidBounce4]), color, capgrpAmmostate);
+               AddCaption(FormatA(trmsg[sidBounce], trmsg[sidBounce4]), color, capgrpAmmostate);
                CurWeapon^.Bounciness:= 2000;
                end;
             5: begin
-               AddCaption(FormatPChar(trmsg[sidBounce], trmsg[sidBounce5]), color, capgrpAmmostate);
+               AddCaption(FormatA(trmsg[sidBounce], trmsg[sidBounce5]), color, capgrpAmmostate);
                CurWeapon^.Bounciness:= 4000;
                end
             end
@@ -533,7 +533,7 @@
         if (Ammoz[a].Ammo.NumPerTurn >= MultiShootAttacks) then
             begin
             s:= inttostr(Ammoz[a].Ammo.NumPerTurn - MultiShootAttacks + 1);
-            AddCaption(formatPChar(trmsg[sidRemaining], Str2Pchar(s)), cWhiteColor, capgrpAmmostate);
+            AddCaption(format(trmsg[sidRemaining], s), cWhiteColor, capgrpAmmostate);
             end;
 
         if (Ammoz[a].Ammo.NumPerTurn >= MultiShootAttacks)
@@ -651,7 +651,7 @@
             s:= trammo[Ammoz[ammo].NameId] + ' (+' + IntToStr(cnt) + ')'
         else
             s:= trammo[Ammoz[ammo].NameId] + ' (+' + IntToStr(Ammoz[ammo].NumberInCase) + ')';
-        AddCaption(Str2PChar(s), HH.Team^.Clan^.Color, capgrpAmmoinfo);
+        AddCaption(s, HH.Team^.Clan^.Color, capgrpAmmoinfo);
 
         // show ammo icon
         vga:= AddVisualGear(X, Y, vgtAmmo);
@@ -714,7 +714,7 @@
                     HH^.Hedgehog^.Effects[hePoisoned] := 0;
                     str(Gear^.Health, s);
                     s:= '+' + s;
-                    AddCaption(Str2PChar(s), HH^.Hedgehog^.Team^.Clan^.Color, capgrpAmmoinfo);
+                    AddCaption(s, HH^.Hedgehog^.Team^.Clan^.Color, capgrpAmmoinfo);
                     RenderHealth(HH^.Hedgehog^);
                     RecountTeamHealth(HH^.Hedgehog^.Team);
 
@@ -1268,7 +1268,7 @@
                 Gear^.State:= (Gear^.State or gstHHDeath) and (not gstAnimation);
                 Gear^.doStep:= @doStepHedgehogDead;
                 // Death message
-                AddCaption(FormatPChar(GetEventString(eidDied), Str2PChar(Gear^.Hedgehog^.Name)), cWhiteColor, capgrpMessage);
+                AddCaption(Format(GetEventString(eidDied), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage);
                 end;
             end
         else
@@ -1277,7 +1277,7 @@
             Gear^.doStep:= @doStepHedgehogGone;
 
             // Gone message
-            AddCaption(FormatPChar(GetEventString(eidGone), Str2PChar(Gear^.Hedgehog^.Name)), cWhiteColor, capgrpMessage);
+            AddCaption(Format(GetEventString(eidGone), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage);
             end
         end;
     exit
--- a/hedgewars/uGearsUtils.pas	Fri Feb 07 00:47:51 2014 +0400
+++ b/hedgewars/uGearsUtils.pas	Thu Feb 06 22:03:53 2014 +0100
@@ -234,7 +234,7 @@
                     inc(CurrentHedgehog^.Gear^.Health,vampDmg);
                     str(vampDmg, s);
                     s:= '+' + s;
-                    AddCaption(Str2PChar(s), CurrentHedgehog^.Team^.Clan^.Color, capgrpAmmoinfo);
+                    AddCaption(s, CurrentHedgehog^.Team^.Clan^.Color, capgrpAmmoinfo);
                     RenderHealth(CurrentHedgehog^);
                     RecountTeamHealth(CurrentHedgehog^.Team);
                     i:= 0;
@@ -419,7 +419,7 @@
                             begin
                             Gear^.doStep := @doStepDrowningGear;
                             Gear^.State := Gear^.State and (not gstHHDriven);
-                            AddCaption(FormatPChar(GetEventString(eidDrowned), Str2PChar(Gear^.Hedgehog^.Name)), cWhiteColor, capgrpMessage);
+                            AddCaption(Format(GetEventString(eidDrowned), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage);
                             end
                         end
                     else
--- a/hedgewars/uLocale.pas	Fri Feb 07 00:47:51 2014 +0400
+++ b/hedgewars/uLocale.pas	Thu Feb 06 22:03:53 2014 +0100
@@ -25,7 +25,6 @@
 const MAX_EVENT_STRINGS = 100;
 
 procedure LoadLocale(FileName: shortstring);
-function  FormatPChar(fmt: PChar; arg: PChar): PChar;
 function  Format(fmt: shortstring; var arg: shortstring): shortstring;
 function  FormatA(fmt: PChar; arg: ansistring): ansistring;
 function  GetEventString(e: TEventId): PChar;
@@ -110,14 +109,6 @@
         GetEventString:= trevt[e][GetRandom(trevt_n[e])]; // Pick a random message and return it
 end;
 
-function FormatPChar(fmt: PChar; arg: PChar): PChar;
-var
-    s: shortstring;
-begin
-    s:= arg;
-    FormatPChar:= Str2PChar(FormatA(fmt, s));
-end;
-
 function Format(fmt: shortstring; var arg: shortstring): shortstring;
 var i: LongInt;
 begin
--- a/hedgewars/uRenderUtils.pas	Fri Feb 07 00:47:51 2014 +0400
+++ b/hedgewars/uRenderUtils.pas	Thu Feb 06 22:03:53 2014 +0100
@@ -35,8 +35,7 @@
 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean);
 
 function  RenderStringTex(s: ansistring; Color: Longword; font: THWFont): PTexture;
-function  RenderStringTexPChar(s: PChar; Color: Longword; font: THWFont): PTexture;
-function  RenderStringTexLim(s: PChar; Color: Longword; font: THWFont; maxLength: LongWord): PTexture;
+function  RenderStringTexLim(s: ansistring; Color: Longword; font: THWFont; maxLength: LongWord): PTexture;
 function  RenderSpeechBubbleTex(s: ansistring; SpeechType: Longword; font: THWFont): PTexture;
 
 implementation
@@ -77,13 +76,13 @@
     WriteInRoundRect:= WriteInRoundRect(Surface, X, Y, Color, Font, s, 0);
 end;*)
 
-function WriteInRoundRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: PChar; maxLength: LongWord): TSDL_Rect;
+function WriteInRoundRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: ansistring; maxLength: LongWord): TSDL_Rect;
 var w, h: LongInt;
     tmpsurf: PSDL_Surface;
     clr: TSDL_Color;
     finalRect, textRect: TSDL_Rect;
 begin
-    TTF_SizeUTF8(Fontz[Font].Handle, s, @w, @h);
+    TTF_SizeUTF8(Fontz[Font].Handle, Str2PChar(s), @w, @h);
     if (maxLength <> 0) and (w > maxLength) then w := maxLength;
     finalRect.x:= X;
     finalRect.y:= Y;
@@ -97,7 +96,7 @@
     clr.r:= (Color shr 16) and $FF;
     clr.g:= (Color shr 8) and $FF;
     clr.b:= Color and $FF;
-    tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, s, clr);
+    tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, Str2PChar(s), clr);
     finalRect.x:= X + cFontBorder + 2;
     finalRect.y:= Y + cFontBorder;
     SDLTry(tmpsurf <> nil, true);
@@ -271,22 +270,17 @@
 
 function RenderStringTex(s: ansistring; Color: Longword; font: THWFont): PTexture;
 begin
-    RenderStringTex:= RenderStringTexLim(Str2PChar(s), Color, font, 0);
+    RenderStringTex:= RenderStringTexLim(s, Color, font, 0);
 end;
 
-function RenderStringTexPChar(s: PChar; Color: Longword; font: THWFont): PTexture;
-begin
-    RenderStringTexPChar:= RenderStringTexLim(s, Color, font, 0);
-end;
-
-function RenderStringTexLim(s: PChar; Color: Longword; font: THWFont; maxLength: LongWord): PTexture;
+function RenderStringTexLim(s: ansistring; Color: Longword; font: THWFont; maxLength: LongWord): PTexture;
 var w, h: LongInt;
     finalSurface: PSDL_Surface;
 begin
-    if s[0] = #0 then s:= Str2PChar(' '); // conversion because pas2c ain't smart enough yet;
+    if length(s) = 0 then s:= _S' ';
     font:= CheckCJKFont(s, font);
     w:= 0; h:= 0; // avoid compiler hints
-    TTF_SizeUTF8(Fontz[font].Handle, s, @w, @h);
+    TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(s), @w, @h);
     if (maxLength <> 0) and (w > maxLength) then w := maxLength;
 
     finalSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, w + cFontBorder * 2 + 4, h + cFontBorder * 2,
@@ -342,7 +336,7 @@
 
     if length(s) = 0 then
         s:= '...';
-    font:= CheckCJKFont(Str2PChar(s), font);
+    font:= CheckCJKFont(s, font);
     w:= 0; h:= 0; // avoid compiler hints
     TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(s), @w, @h);
     if w<8 then
--- a/hedgewars/uStats.pas	Fri Feb 07 00:47:51 2014 +0400
+++ b/hedgewars/uStats.pas	Thu Feb 06 22:03:53 2014 +0100
@@ -112,7 +112,7 @@
         begin
         AddVoice(sndStupid, PreviousTeam^.voicepack);
         if CurrentHedgehog^.stats.DamageGiven = CurrentHedgehog^.stats.StepDamageRecv then
-            AddCaption(FormatPChar(GetEventString(eidHurtSelf), Str2PChar(CurrentHedgehog^.Name)), cWhiteColor, capgrpMessage);
+            AddCaption(Format(GetEventString(eidHurtSelf), CurrentHedgehog^.Name), cWhiteColor, capgrpMessage);
         end
 
     else if DamageClan <> 0 then
@@ -140,7 +140,7 @@
     else if isTurnSkipped then
         begin
         AddVoice(sndBoring, PreviousTeam^.voicepack);
-        AddCaption(FormatPChar(GetEventString(eidTurnSkipped), Str2PChar(CurrentHedgehog^.Name)), cWhiteColor, capgrpMessage);
+        AddCaption(Format(GetEventString(eidTurnSkipped), CurrentHedgehog^.Name), cWhiteColor, capgrpMessage);
         end
     else if not PlacingHogs then
         AddVoice(sndCoward, PreviousTeam^.voicepack);
--- a/hedgewars/uStore.pas	Fri Feb 07 00:47:51 2014 +0400
+++ b/hedgewars/uStore.pas	Thu Feb 06 22:03:53 2014 +0100
@@ -185,9 +185,9 @@
 for t:= 0 to Pred(TeamsCount) do
     with TeamsArray[t]^ do
         begin
-        NameTagTex:= RenderStringTexLim(Str2PChar(TeamName), Clan^.Color, Font, cTeamHealthWidth);
+        NameTagTex:= RenderStringTexLim(TeamName, Clan^.Color, Font, cTeamHealthWidth);
         if length(Owner) > 0 then
-            OwnerTex:= RenderStringTexLim(Str2PChar(Owner), Clan^.Color, Font, cTeamHealthWidth);
+            OwnerTex:= RenderStringTexLim(Owner, Clan^.Color, Font, cTeamHealthWidth);
 
         r.x:= 0;
         r.y:= 0;
@@ -261,7 +261,7 @@
             with Hedgehogs[i] do
                 if Gear <> nil then
                     begin
-                    NameTagTex:= RenderStringTexLim(Str2PChar(Name), Clan^.Color, fnt16, cTeamHealthWidth);
+                    NameTagTex:= RenderStringTexLim(Name, Clan^.Color, fnt16, cTeamHealthWidth);
                     if Hat = 'NoHat' then
                         begin
                         if (month = 4) and (md = 20) then
@@ -438,10 +438,10 @@
 
 InitHealth;
 
-PauseTexture:= RenderStringTexPChar(trmsg[sidPaused], cYellowColor, fntBig);
-AFKTexture:= RenderStringTexPChar(trmsg[sidAFK], cYellowColor, fntBig);
-ConfirmTexture:= RenderStringTexPChar(trmsg[sidConfirm], cYellowColor, fntBig);
-SyncTexture:= RenderStringTexPChar(trmsg[sidSync], cYellowColor, fntBig);
+PauseTexture:= RenderStringTex(trmsg[sidPaused], cYellowColor, fntBig);
+AFKTexture:= RenderStringTex(trmsg[sidAFK], cYellowColor, fntBig);
+ConfirmTexture:= RenderStringTex(trmsg[sidConfirm], cYellowColor, fntBig);
+SyncTexture:= RenderStringTex(trmsg[sidSync], cYellowColor, fntBig);
 
 if not reload then
     AddProgress;
@@ -450,8 +450,8 @@
 for ai:= Low(TAmmoType) to High(TAmmoType) do
     with Ammoz[ai] do
         begin
-        TryDo(trAmmo[NameId][0] <> #0,'No default text/translation found for ammo type #' + intToStr(ord(ai)) + '!',true);
-        tmpsurf:= TTF_RenderUTF8_Blended(Fontz[CheckCJKFont(trAmmo[NameId],fnt16)].Handle, trAmmo[NameId], cWhiteColorChannels);
+        TryDo(trAmmo[NameId] <> '','No default text/translation found for ammo type #' + intToStr(ord(ai)) + '!',true);
+        tmpsurf:= TTF_RenderUTF8_Blended(Fontz[CheckCJKFont(trAmmo[NameId],fnt16)].Handle, Str2PChar(trAmmo[NameId]), cWhiteColorChannels);
         TryDo(tmpsurf <> nil,'Name-texture creation for ammo type #' + intToStr(ord(ai)) + ' failed!',true);
         tmpsurf:= doSurfaceConversion(tmpsurf);
         FreeTexture(NameTex);
@@ -1238,10 +1238,10 @@
     tmpline, tmpline2, tmpdesc: ansistring;
 begin
 // make sure there is a caption as well as a sub caption - description is optional
-if caption[0] = #0 then
-    caption:= Str2PChar(_S'???');
-if subcaption[0] = #0 then
-    subcaption:= Str2PChar(_S' ');
+if caption = '' then
+    caption:= '???';
+if subcaption = '' then
+    subcaption:= _S' ';
 
 font:= CheckCJKFont(caption,fnt16);
 font:= CheckCJKFont(subcaption,font);
@@ -1285,7 +1285,7 @@
         end
     end;
 
-if extra[0] <> #0 then
+if extra <> '' then
     begin
     // get extra label's dimensions
     TTF_SizeUTF8(Fontz[font].Handle, extra, @i, @j);
@@ -1332,7 +1332,7 @@
         end
     end;
 
-if extra[0] <> #0 then
+if extra <> '' then
     r:= WriteInRect(tmpsurf, cFontBorder + 2, r.y + r.h, extracolor, font, extra);
 
 r.x:= cFontBorder + 6;
@@ -1370,7 +1370,7 @@
 r.h:= 32;
 
 // default (no extra text)
-extra:= Str2PChar(''); // conversion because pas2c ain't smart enough yet
+extra:= _S'';
 extracolor:= 0;
 
 if (CurrentTeam <> nil) and (Ammoz[atype].SkipTurns >= CurrentTeam^.Clan^.TurnNumber) then // weapon or utility is not yet available
@@ -1385,7 +1385,7 @@
     end
 else
     begin
-    extra:= Str2PChar(''); // conversion because pas2c ain't smart enough yet
+    extra:= _S'';
     extracolor:= 0;
     end;
 
--- a/hedgewars/uTeams.pas	Fri Feb 07 00:47:51 2014 +0400
+++ b/hedgewars/uTeams.pas	Thu Feb 06 22:03:53 2014 +0100
@@ -103,7 +103,7 @@
             else
                 AddVoice(sndVictory, Teams[0]^.voicepack);
 
-            AddCaption(Str2PChar(s), cWhiteColor, capgrpGameState);
+            AddCaption(s, cWhiteColor, capgrpGameState);
             SendStat(siGameResult, s);
             AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000)
             end;
@@ -334,7 +334,7 @@
         end;
     if cHedgehogTurnTime < 1000000 then
         ReadyTimeLeft:= cReadyDelay;
-    AddCaption(FormatPChar(trmsg[sidReady], Str2PChar(CurrentTeam^.TeamName)), cWhiteColor, capgrpGameState)
+    AddCaption(Format(shortstring(trmsg[sidReady]), CurrentTeam^.TeamName), cWhiteColor, capgrpGameState)
     end
 else
     begin
--- a/hedgewars/uUtils.pas	Fri Feb 07 00:47:51 2014 +0400
+++ b/hedgewars/uUtils.pas	Thu Feb 06 22:03:53 2014 +0100
@@ -60,7 +60,7 @@
 
 function  endian(independent: LongWord): LongWord; inline;
 
-function  CheckCJKFont(s: PChar; font: THWFont): THWFont;
+function  CheckCJKFont(s: ansistring; font: THWFont): THWFont;
 
 procedure AddFileLog(s: shortstring);
 procedure AddFileLogRaw(s: pchar); cdecl;
@@ -364,7 +364,7 @@
 {$ENDIF}
 end;
 
-function CheckCJKFont(s: PChar; font: THWFont): THWFont;
+function CheckCJKFont(s: ansistring; font: THWFont): THWFont;
 var l, i : LongInt;
     u: WideChar;
     tmpstr: array[0..256] of WideChar;
@@ -373,11 +373,11 @@
 
 {$IFNDEF MOBILE}
 // remove chinese fonts for now
-if (font >= CJKfnt16) or (StrLength(s) = 0) then
+if (font >= CJKfnt16) or (length(s) = 0) then
 {$ENDIF}
     exit;
 
-l:= Utf8ToUnicode(@tmpstr, s, StrLength(s))-1;
+l:= Utf8ToUnicode(@tmpstr, Str2PChar(s), length(s))-1;
 i:= 0;
 
 while i < l do