Lazarus
September 02, 2010, 05:12:20 pm *
  Home   Forum   Help Search Login Register  
* * *
Pages: [1]
  Print  
Author Topic: ASCII Strings  (Read 345 times)
Alex Cones
Newbie
*
Posts: 14


WWW
« on: July 29, 2010, 06: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:
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:
S := Chr($C0) + Chr($C1) + Chr($C2);
Then I have a correct string and can to compare symbols:
Code:
If S[1] = 'А' (* Russian 'A' *) Then ...
Logged
typo
Sr. Member
****
Posts: 320


« Reply #1 on: July 29, 2010, 06:18:34 pm »

But if you write:

Code:
If UTF8Copy(s, 1, 1) = 'П' Then ShowMessage('!'); 

you have the message.

uses lclproc.
« Last Edit: July 29, 2010, 06:20:49 pm by typo » Logged
theo
Global Moderator
Hero Member
*****
Posts: 1336


« Reply #2 on: July 29, 2010, 06:21:50 pm »

Lazarus uses UTF-8 not ANSI.

The function Typo mentions is in unit LCLProc.
Logged
Alex Cones
Newbie
*
Posts: 14


WWW
« Reply #3 on: July 29, 2010, 07:10:01 pm »

It can be solved without lclproc module?
Logged
theo
Global Moderator
Hero Member
*****
Posts: 1336


« Reply #4 on: July 29, 2010, 07: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
Logged
Alex Cones
Newbie
*
Posts: 14


WWW
« Reply #5 on: July 30, 2010, 07: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, 08:02:01 pm by Alex Cones » Logged
Pages: [1]
  Print  
 
Jump to:  

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads
TinyPortal v1.0 beta 4 © Bloc
Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!