Because Length() returns bytes count.
Have lazarus conventional function to calculate chars count in string, that do it independently from its binary representation ? "Length() div 2" is not conventional nor portable.
Mailing lists / lazarus / 2008-06
I cannot use System.Length() to calculate visible width of string, now !
10 messages · 7 people · –
- MMattias Gaertner 2
- ААндрей Гусев 2
- ААндрей Гусев Andrey Gusev 2
- AAndrey Gu 1
- FFelipe Monteiro de Carvalho 1
- GGraeme Geldenhuys 1
- +1 more
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
You mean like the UTF8Length() function in LCLProc unit?
Graeme.
?????? ????? wrote 10 lines
Graeme Geldenhuys wroteYou mean like the UTF8Length() function in LCLProc unit?
He mean that, but that is not independently from its binary representation: it assume UTF8 binary representation.
OTOH, I don't think you can make a function Length without telling it (implicitly or explicitly by using a parameter) the used encoding.
Show quoted text 6 lines
Vincent
You mean like the UTF8Length() function in LCLProc unit? Graeme. - Graeme -…
Yes. But UTF8Length() is portable between string encodings? Solution is clean: i must use check ifdef'ed WindowsUnicodeSupport to choice between UTF8Length()/Length(). But maybe it already implemented as universal and conventional solution.
And, that adjanced questuion:
Lazarus, guessed, have a tool to recognize encoding by binary representation of string
(because Lazarus automatically recognize encodings in LFM files), so, how i can use it ?
Graeme Geldenhuys ?????:
Show quoted text 22 lines
?????? ????? wroteYes. But UTF8Length() is portable between string encodings?
It only works in utf-8 strings
Solution is clean: i must use check ifdef'ed WindowsUnicodeSupport to choice between UTF8Length()/Length(). But maybe it already implemented as universal and conventional solution.
Why do you want to support disabled WindowsUnicodeSupport?
Felipe Monteiro de Carvalho ?????:
Show quoted text 8 lines
Caption strings in some forms of my project must be defined dynamically. Unit code, responsible to these strings definition and visible elemsnts dosposal, is universal and low-level.
I wouldn't like make assumtions about strings encoding in that code. That is my problem.
Have Lasarus way to solve it ?
Show quoted text 11 lines
Do you mean like this:
http://wiki.lazarus.freepascal.org/Translations_/_i18n_/_localizations_for_programs#Translating_Forms.2C_Datamodules_and_Frames
Show quoted text 5 lines
Why not use only UTF-8 like the IDE?
Mattias
Yes. But UTF8Length() is portable between string encodings? Solution is clean: i must use…
Show quoted text 10 lines
There is a simple heuristic.
The function is in lcl/lconvencoding.pas function GuessEncoding.
Mattias
On Fri, 20 Jun 2008 13:23:04 +0400 Do you mean like this:…
Mattias Gaertner ?????:
Show quoted text 23 lines
Not.
I alreary rework my code generation scripts to get UTF8-sources.
Show quoted text 11 lines
I wish to save maxumum compatibility level to (probably) backporting to Delphi.
Yes, yes, i must use {$ifdefs}.
On Thu, 19 Jun 2008 17:19:59 +0400 There is a simple heuristic. The function is in…
Mattias Gaertner ?????:
Show quoted text 20 lines
Thanks.
