Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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: 13980
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 May 23 14:08:07 CEST 2024

Total time taken to generate the page: 0.02073 seconds