Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2010-05

UTF8Decode

10 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Luis Fernando Del Aguila Mejía

When compiling this program http://www.conoce3000.com/Test.pp in Windows receive the following error:

  Test.pp(4,11) Error: Can't determine which overloaded function to call

The problem only happens when I use a utf8 character. What am I doing wrong?
In Linux, the program compile OK.

Reply by email

Jonas Maebe
to Luis Fernando Del Aguila Mejía
Luis Fernando Del Aguila Mejía wrote 5 lines
When compiling this program http://www.conoce3000.com/Test.pp in Windows receive the following error: Test.pp(4,11) Error: Can't determine which overloaded function to call The problem only happens when I use a utf8 character. What am I doing wrong? In Linux, the program compile OK.

If you compile with -vh, then the compiler will tell you which function definitions it found:

tt.pp(4,11) Error: Can't determine which overloaded function to call
wstrings.inc(1623,10) Hint: Found declaration: UTF8Encode(const WideString):AnsiString;
ustrings.inc(2281,10) Hint: Found declaration: UTF8Encode(const UnicodeString):AnsiString;

The reason it works on Unix platforms, is that widestring=unicodestring there (so there is nothing to choose between if you pass a wide/unicodechar). You can solve it by typecasting the character explicitly to either widestring or unicodestring.

Jonas

Reply by email

Vincent Snijders
to Graeme Geldenhuys
Graeme Geldenhuys wrote 5 lines
Luis Fernando Del Aguila Mejía het geskryf: > Why WideString is not equal to Unicodestring in Windows? WideString is reference counted (for Windows COM reasons). UnicodeString is pretty much the same as WideString, but not reference counted.

I am pretty sure it is the other way around, UnicodeString is the unicode version of AnsiString and is thus reference counted. WideString is the OLEstring compatible string, and is not reference counted.

Vincent

Reply by email

Michael Van Canneyt
to Vincent Snijders
Vincent Snijders wrote 10 lines
Graeme Geldenhuys schreef: > Luis Fernando Del Aguila Mejía het geskryf: >> Why WideString is not equal to Unicodestring in Windows? > > WideString is reference counted (for Windows COM reasons). UnicodeString is > pretty much the same as WideString, but not reference counted. I am pretty sure it is the other way around, UnicodeString is the unicode version of AnsiString and is thus reference counted. WideString is the OLEstring compatible string, and is not reference counted.

Correct.

Michael.

Reply by email

Graeme Geldenhuys
to Vincent Snijders: I am pretty sure it is the other way around, UnicodeString is the unicode version of…

Vincent Snijders het geskryf:

I am pretty sure it is the other way around, UnicodeString is the unicode version of AnsiString and is thus reference counted. WideString is the OLEstring compatible string, and is not reference counted.

My mistake... only made my first cup of coffee now. :-)

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Reply by email

Graeme Geldenhuys
to Michael Van Canneyt: Correct. Michael.

Michael Van Canneyt het geskryf:

Show quoted text 5 lines
> I am pretty sure it is the other way around, UnicodeString is the unicode > version of AnsiString and is thus reference counted. WideString is the > OLEstring compatible string, and is not reference counted. Correct.

In that case the FPC documentation is wrong. Then could you correct the ref documentation please - Section 3.2.5. As quoted below, the docs say WideString is reference counted.

----------[ FPC 2.4 language reference doc ]----------------- 3.2.5 WideStrings
Widestrings (used to represent unicode character strings) are implemented in much the same way as ansistrings: reference counted, null-terminated arrays, only they are implemented as arrays of WideChars instead of regular Chars.
--------------------------------------------------------------

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Reply by email

Michael Van Canneyt
to Graeme Geldenhuys
Graeme Geldenhuys wrote 19 lines
Michael Van Canneyt het geskryf: >> I am pretty sure it is the other way around, UnicodeString is the unicode >> version of AnsiString and is thus reference counted. WideString is the >> OLEstring compatible string, and is not reference counted. > > Correct. In that case the FPC documentation is wrong. Then could you correct the ref documentation please - Section 3.2.5. As quoted below, the docs say WideString is reference counted. ----------[ FPC 2.4 language reference doc ]----------------- 3.2.5 WideStrings Widestrings (used to represent unicode character strings) are implemented in much the same way as ansistrings: reference counted, null-terminated arrays, only they are implemented as arrays of WideChars instead of regular Chars. --------------------------------------------------------------

Aloha.... My mistake. Will correct ASAP !!

Michael.

Reply by email

spir ☣
to Graeme Geldenhuys: Michael Van Canneyt het geskryf: In that case the FPC documentation is wrong. Then could…
Show quoted text 12 lines
In that case the FPC documentation is wrong. Then could you correct the ref documentation please - Section 3.2.5. As quoted below, the docs say WideString is reference counted. ----------[ FPC 2.4 language reference doc ]----------------- 3.2.5 WideStrings Widestrings (used to represent unicode character strings) are implemented in much the same way as ansistrings: reference counted, null-terminated arrays, only they are implemented as arrays of WideChars instead of regular Chars. --------------------------------------------------------------

Sorry for highjacking the thread: I take the opportunity to ask about string size. Is it maintained in the data structure, or computed when required? (I mean: is there a notable cost for length()?)

Denis
________________________________

vit esse estrany ☣

spir.wikidot.com

Reply by email