Recent

Author Topic: ASCII Strings  (Read 6373 times)

Alex Cones

  • Jr. Member
  • **
  • Posts: 73
    • FLSoft
ASCII Strings
« on: July 29, 2010, 07:08:22 pm »
Hello!

I have problem with a storage strings in ASCII. I trying to use String, ShortString, AnsiString, but I don`t have a correct symbols.

For ex.:
Code: [Select]
Var
 S : String;
Begin
 S := 'Привет всем русским'; //Russian symbols (128-255 part of ASCII)
If S[1] = 'П' Then ShowMessage('!');

I don`t have a message. If I try to show this I have a 'R®¤~  °®' like string;

How to solve this problem?
--------------------
I find only one way:
Code: [Select]
S := Chr($C0) + Chr($C1) + Chr($C2);Then I have a correct string and can to compare symbols:
Code: [Select]
If S[1] = 'А' (* Russian 'A' *) Then ...
To beer or not to beer?
_____________________
I`m terribly sorry for my Anglish. :)

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: ASCII Strings
« Reply #1 on: July 29, 2010, 07:18:34 pm »
But if you write:

Code: [Select]
If UTF8Copy(s, 1, 1) = 'П' Then ShowMessage('!'); 
you have the message.

uses lclproc.
« Last Edit: July 29, 2010, 07:20:49 pm by typo »

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1931
Re: ASCII Strings
« Reply #2 on: July 29, 2010, 07:21:50 pm »
Lazarus uses UTF-8 not ANSI.

The function Typo mentions is in unit LCLProc.

Alex Cones

  • Jr. Member
  • **
  • Posts: 73
    • FLSoft
Re: ASCII Strings
« Reply #3 on: July 29, 2010, 08:10:01 pm »
It can be solved without lclproc module?
To beer or not to beer?
_____________________
I`m terribly sorry for my Anglish. :)

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1931
Re: ASCII Strings
« Reply #4 on: July 29, 2010, 08:20:38 pm »
It can be solved without lclproc module?

You could use my utf8scanner.pas if you like.
http://wiki.lazarus.freepascal.org/Theodp

Alex Cones

  • Jr. Member
  • **
  • Posts: 73
    • FLSoft
Re: ASCII Strings
« Reply #5 on: July 30, 2010, 08:55:24 am »
I`ll think about more solutions. Anyway thank you.
------------------------
I found default functions UTF8ToAnsi & AnsiToUTF8 [wstringh.inc]. It`s killed me.
« Last Edit: July 30, 2010, 09:02:01 pm by Alex Cones »
To beer or not to beer?
_____________________
I`m terribly sorry for my Anglish. :)

 

TinyPortal © 2005-2018