U++ framework
Do not panic. Ask here before giving up.

Home » U++ Library support » U++ Core » [SOLVED] String.GetCount with umlaut
Re: String.GetCount with umlaut [message #33713 is a reply to message #33707] Wed, 07 September 2011 09:46 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
forlano wrote on Tue, 06 September 2011 17:12

Hello,

GetCount() returns 7 for the string "lubäck" Surprised

I see only 6 characters. Where is the trick?
I guess 'ä' is counted twice, but how can I know how many characters are really there in a string?



GetCount or GetLength returns a number of _bytes_ in string.

When it is UTF-8 encoded, this is more than number of characters it represents.

Good way to convert is

.ToWString().GetCount()

or you can use "utf8len" function too..

(Anyway, thinking about it, perhaps I shall add "GetCharCount()" method to String...).

Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Array : swapping element with a pointer
Next Topic: Core: Null handling incoherent?
Goto Forum:
  


Current Time: Thu Sep 24 22:00:22 GMT+2 2026

Total time taken to generate the page: 0.00837 seconds