hedgewars/uUtils.pas
branchwebgl
changeset 8833 c13ebed437cb
parent 8444 75db7bb8dce8
parent 8575 228fbb2a76a4
child 8841 338f7c2bac2c
equal deleted inserted replaced
8450:404ddce27b23 8833:c13ebed437cb
    85 procedure saveFinishedSynching; cdecl; external;
    85 procedure saveFinishedSynching; cdecl; external;
    86 function  isApplePhone: Boolean; cdecl; external;
    86 function  isApplePhone: Boolean; cdecl; external;
    87 procedure AudioServicesPlaySystemSound(num: LongInt); cdecl; external;
    87 procedure AudioServicesPlaySystemSound(num: LongInt); cdecl; external;
    88 {$ENDIF}
    88 {$ENDIF}
    89 
    89 
       
    90 function  sanitizeForLog(s: shortstring): shortstring;
       
    91 function  sanitizeCharForLog(c: char): shortstring;
       
    92 
    90 procedure initModule(isNotPreview: boolean);
    93 procedure initModule(isNotPreview: boolean);
    91 procedure freeModule;
    94 procedure freeModule;
    92 
    95 
    93 
    96 
    94 implementation
    97 implementation
   373     begin
   376     begin
   374     u:= tmpstr[i];
   377     u:= tmpstr[i];
   375     if (#$1100  <= u) and  (
   378     if (#$1100  <= u) and  (
   376                            (u <= #$11FF )  or // Hangul Jamo
   379                            (u <= #$11FF )  or // Hangul Jamo
   377        ((#$2E80  <= u) and (u <= #$2FDF))  or // CJK Radicals Supplement / Kangxi Radicals
   380        ((#$2E80  <= u) and (u <= #$2FDF))  or // CJK Radicals Supplement / Kangxi Radicals
   378        ((#$2FF0  <= u) and (u <= #$303F))  or // Ideographic Description Characters / CJK Radicals Supplement
   381        ((#$2FF0  <= u) and (u <= #$31FF))  or // Ideographic Description Characters / CJK Radicals Supplement / Hiragana / Hangul Compatibility Jamo / Katakana
   379        ((#$3130  <= u) and (u <= #$318F))  or // Hangul Compatibility Jamo
       
   380        ((#$31C0  <= u) and (u <= #$31EF))  or // CJK Strokes
   382        ((#$31C0  <= u) and (u <= #$31EF))  or // CJK Strokes
   381        ((#$3200  <= u) and (u <= #$4DBF))  or // Enclosed CJK Letters and Months / CJK Compatibility / CJK Unified Ideographs Extension A
   383        ((#$3200  <= u) and (u <= #$4DBF))  or // Enclosed CJK Letters and Months / CJK Compatibility / CJK Unified Ideographs Extension A / Circled Katakana
   382        ((#$4E00  <= u) and (u <= #$9FFF))  or // CJK Unified Ideographs
   384        ((#$4E00  <= u) and (u <= #$9FFF))  or // CJK Unified Ideographs
   383        ((#$AC00  <= u) and (u <= #$D7AF))  or // Hangul Syllables
   385        ((#$AC00  <= u) and (u <= #$D7AF))  or // Hangul Syllables
   384        ((#$F900  <= u) and (u <= #$FAFF))  or // CJK Compatibility Ideographs
   386        ((#$F900  <= u) and (u <= #$FAFF))  or // CJK Compatibility Ideographs
   385        ((#$FE30  <= u) and (u <= #$FE4F)))    // CJK Compatibility Forms
   387        ((#$FE30  <= u) and (u <= #$FE4F))  or // CJK Compatibility Forms
   386        then
   388        ((#$FF66  <= u) and (u <= #$FF9D)))    // halfwidth katakana
       
   389        then 
   387         begin
   390         begin
   388             CheckCJKFont:=  THWFont( ord(font) + ((ord(High(THWFont))+1) div 2) );
   391             CheckCJKFont:=  THWFont( ord(font) + ((ord(High(THWFont))+1) div 2) );
   389             exit;
   392             exit;
   390         end;
   393         end;
   391     inc(i)
   394     inc(i)
   454 //    getScreenDPI:= Android_JNI_getDensity();
   457 //    getScreenDPI:= Android_JNI_getDensity();
   455     getScreenDPI:= 1;
   458     getScreenDPI:= 1;
   456 {$ELSE}
   459 {$ELSE}
   457     getScreenDPI:= 1;
   460     getScreenDPI:= 1;
   458 {$ENDIF}
   461 {$ENDIF}
       
   462 end;
       
   463 
       
   464 function  sanitizeForLog(s: shortstring): shortstring;
       
   465 var i: byte;
       
   466     r: shortstring;
       
   467 begin
       
   468     r[0]:= s[0];
       
   469     for i:= 1 to length(s) do
       
   470         if (s[i] < #32) or (s[i] > #127) then
       
   471             r[i]:= '?'
       
   472             else
       
   473             r[i]:= s[i];
       
   474             
       
   475     sanitizeForLog:= r
       
   476 end;
       
   477 
       
   478 function  sanitizeCharForLog(c: char): shortstring;
       
   479 var r: shortstring;
       
   480 begin
       
   481     if (c < #32) or (c > #127) then
       
   482         r:= '#' + inttostr(byte(c))
       
   483         else
       
   484         r:= c;
       
   485             
       
   486     sanitizeCharForLog:= r
   459 end;
   487 end;
   460 
   488 
   461 procedure initModule(isNotPreview: boolean);
   489 procedure initModule(isNotPreview: boolean);
   462 {$IFDEF DEBUGFILE}
   490 {$IFDEF DEBUGFILE}
   463 var logfileBase: shortstring;
   491 var logfileBase: shortstring;