Forum > General

[SOLVED] Replacing a non-ascii chars in UTF8 string

<< < (2/2)

SymbolicFrank:
Letter E

Note the letters that look like 'H' and such.

I just checked and the Cyrillic "E" isn't even in the picture. There are far too many E's to fit the box.

wp:
Using the string iterator of unit LazUnicode it is easy to run through the UTF8 codepoints of an input string and replace them as needed.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses  LazUnicode; function CheckAndReplace(const AText: String): String;var  cyrillicCh, latinCh: String;begin  Result := '';  for cyrillicCh in AText do  begin    case cyrillicCh of      'А': latinCh := 'A';      'В': latinCh := 'B';      'е': latinCh := 'e';      'І': latinCh := 'I';      'Ѕ': latinCh := 'S';      'О': latinCh := 'O';      'Р': latinCh := 'P';      'Т': latinCh := 'T';      'С': latinCh := 'C';      'М': latinCh := 'M';      'Н': latinCh := 'H';      'а': latinCh := 'a';      'о': latinCh := 'o';      'р': latinCh := 'p';      'с': latinCh := 'c';      // add more...      else latinCh := cyrillicCh;      end;    Result := Result + LatinCh;  end;end;

y.ivanov:

--- Quote from: wp on January 15, 2022, 01:25:22 pm ---Using the string iterator of unit LazUnicode it is easy to run through the UTF8 codepoints of an input string and replace them as needed.

--- End quote ---
That's exactly what I've meant. Thanks a lot!

Navigation

[0] Message Index

[*] Previous page

Go to full version