DEADSOFTWARE

fix question char
authorDeaDDooMER <deaddoomer@deadsoftware.ru>
Wed, 30 Oct 2019 15:40:28 +0000 (18:40 +0300)
committerDeaDDooMER <deaddoomer@deadsoftware.ru>
Wed, 30 Oct 2019 15:40:28 +0000 (18:40 +0300)
src/game/sdl2/g_system.pas
src/shared/utils.pas

index 45a45fd54a3c3bf9c6dfaeb29d25f6d5494a5e61..f46c3278669f208ae7258eef957b5caab3991d89 100644 (file)
@@ -408,14 +408,12 @@ implementation
   procedure HandleTextInput (var ev: TSDL_TextInputEvent);
     var ch: UnicodeChar; sch: AnsiChar;
   begin
-    if g_dbg_input then
-      e_LogWritefln('Input Debug: text, text=%s', [ev.text]);
     Utf8ToUnicode(@ch, PChar(ev.text), 1);
-    if IsValid1251(Word(ch)) then
-    begin
-      sch := AnsiChar(wchar2win(ch));
+    sch := AnsiChar(wchar2win(ch));
+    if g_dbg_input then
+      e_LogWritefln('Input Debug: text, text="%s", ch = %s, sch = %s', [ev.text, Ord(ch), Ord(sch)]);
+    if IsValid1251(Word(ch)) and IsPrintable1251(ch) then
       CharPress(sch);
-    end;
   end;
 
   function sys_HandleInput (): Boolean;
index bf8abf4fbc98a8d0ce8de1b687e6b35da9d63cd7..14fa53b94eecb7425bbb1d8b8746eb4e412a5826 100644 (file)
@@ -508,7 +508,7 @@ var
 const
   cp1251: array[0..127] of Word = (
     $0402,$0403,$201A,$0453,$201E,$2026,$2020,$2021,$20AC,$2030,$0409,$2039,$040A,$040C,$040B,$040F,
-    $0452,$2018,$2019,$201C,$201D,$2022,$2013,$2014,$003F,$2122,$0459,$203A,$045A,$045C,$045B,$045F,
+    $0452,$2018,$2019,$201C,$201D,$2022,$2013,$2014,$FFFD,$2122,$0459,$203A,$045A,$045C,$045B,$045F,
     $00A0,$040E,$045E,$0408,$00A4,$0490,$00A6,$00A7,$0401,$00A9,$0404,$00AB,$00AC,$00AD,$00AE,$0407,
     $00B0,$00B1,$0406,$0456,$0491,$00B5,$00B6,$00B7,$0451,$2116,$0454,$00BB,$0458,$0405,$0455,$0457,
     $0410,$0411,$0412,$0413,$0414,$0415,$0416,$0417,$0418,$0419,$041A,$041B,$041C,$041D,$041E,$041F,
@@ -1017,12 +1017,12 @@ end;
 
 function IsValid1251 (ch: Word): Boolean;
 begin
-  result := (ch = Ord('?')) or (wc2shitmap[ch] <> '?')
+  result := ((ch = Ord('?')) or (wc2shitmap[ch] <> '?')) and (ch <> $98)
 end;
 
 function IsPrintable1251 (ch: AnsiChar): Boolean;
 begin
-  result := (ch >= #32) and (ch <> #127)
+  result := (ch >= #32) and (ch <> #127) and (ch <> #$98)
 end;