Recent

Author Topic: accented char  (Read 7515 times)

Paolo

  • Full Member
  • ***
  • Posts: 226
Re: accented char
« Reply #15 on: August 10, 2021, 02:23:16 pm »
thanks engkin,

however in the real situation the file is just one file, say "prova.pas", as soon as possible I'll try to verify "who" or "what" make the file different...

engkin

  • Hero Member
  • *****
  • Posts: 2958
Re: accented char
« Reply #16 on: August 10, 2021, 05:29:32 pm »
You can check if a string is a valid UTF8 string by using FindInvalidUTF8Codepoint from unit LazUtf8, as in:
Code: Pascal  [Select][+][-]
  1. uses ...LazUtf8;
  2. ..
  3.   s:string;
  4.   p:PtrInt;
  5. begin
  6.   s:='ab'#$88'cd';  //<--- not valid because of the #$88
  7.   p:=FindInvalidUTF8Codepoint(@s[1],Length(s),True);
  8.   if p<>-1 then //NOT Valid
  9.  

If your code is for your personal use, or limited to one ANSI codepage, you can use WinCPToUTF8 to correct the string. Otherwise you can provide some mean for the user to choose the correct codepage.

 

TinyPortal © 2005-2018