Recent

Author Topic: Suport to special char's  (Read 5956 times)

everton

  • Jr. Member
  • **
  • Posts: 89
Suport to special char's
« on: June 10, 2011, 06:48:41 pm »
Where's the suport for special characters?

Why I'm not able to do someting like Chr(300)?
or at last something like: UniChar(300), or anything able to do that.

There is any function able to put an special char into a TEdit?

The TEdit aparently support special char's because if I copy and paste the char he puts and display that char.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11818
  • Debugger - SynEdit - and more
    • wiki
Re: Suport to special char's
« Reply #1 on: June 10, 2011, 08:28:42 pm »
char(300) might work for utf16 or utf32 (afaik delphi does utf16)

Lazarus uses utf8, so chars are encoded at variable length. a-z,0-9 are fitting into 1 byte, but others use several bytes.

Google utf8, or search the wiki for utf8.

You can use conversion between utf8 and other chars.

you can use widestring (which afaik has 16 bit chars). But note, that even with 16 bit chars (afaik delphi too) chars may be taking more than those 16 bit.

So Somestring[2] (Never mind if utf8 or utf16) may contain the 2nd char, or it may contain a part (but only a part) of either the 2 or first char.

everton

  • Jr. Member
  • **
  • Posts: 89
Re: Suport to special char's
« Reply #2 on: June 11, 2011, 02:41:27 pm »
The realy question is how to put special char's into a TEdit or any other TControl, because if a copy and paste he put's in there.

How can anyone work with special char's is pascal?

There is a wide range of chars. Take the unicode table's, by i've seen, it's suport more than 1.000.000 of chars.

All this rich is cut of the language that does not have an way to use it.

Hugs,
People.

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Suport to special char's
« Reply #3 on: June 11, 2011, 02:48:10 pm »
You could simply type on your code the character you want to put on edit, for example:

Code: [Select]
Edit1.Text := Edit1.Text + 'º';
« Last Edit: June 11, 2011, 02:50:04 pm by typo »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11818
  • Debugger - SynEdit - and more
    • wiki
Re: Suport to special char's
« Reply #4 on: June 11, 2011, 02:53:33 pm »
I told you, search for utf8 on the wiki, there is a lot of explanation (but I am not going to do the search for you...)

300 / 0x012C   Ĭ   196 172   LATIN CAPITAL LETTER I WITH BREVE

Edit1.Text := Edit1.Text + chr(196) + chr(172);

Read about UTF8, and you will understand this line.

everton

  • Jr. Member
  • **
  • Posts: 89
Re: Suport to special char's
« Reply #5 on: June 11, 2011, 02:56:28 pm »
Hey brother, i got it, so that's is how it is done in Pascal.

Thank's
« Last Edit: June 11, 2011, 02:59:01 pm by everton »

everton

  • Jr. Member
  • **
  • Posts: 89
Re: Suport to special char's
« Reply #6 on: June 11, 2011, 03:07:12 pm »
How about a function in the IDE
to do the math of Unicode number to char?
It would not be great?

I'm not sure if a will code that function right now
because of the going of the projects that i'm envolved with.

But in the future is quite possible.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11818
  • Debugger - SynEdit - and more
    • wiki
Re: Suport to special char's
« Reply #7 on: June 11, 2011, 04:17:33 pm »
you are looking for unit LCLProc?

It has several functions UTF16toXXX
e.g UTF16ToUTF8 (open the unit and search for your self)

var WStr: widestring;
WStr := Widechar(300);

and so on?

However:  even in widechar/widestring some chars are represented by 2 positions in the string.

so WStr[1] may still be only half a char


---
you might be interested in unit LConvEncoding too
« Last Edit: June 11, 2011, 04:21:41 pm by Martin_fr »

 

TinyPortal © 2005-2018