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++ Widgets - General questions or Mixed problems » How to convert utf-8 to (strcmp type)?
How to convert utf-8 to (strcmp type)? [message #30900] Fri, 28 January 2011 02:24 Go to next message
JoseB is currently offline  JoseB
Messages: 37
Registered: March 2009
Member
Hello
How can i convert utf-8 String variable in order to pass it to the strcmp() C++ function?


Thank you

JoseB
Re: How to convert utf-8 to (strcmp type)? [message #30904 is a reply to message #30900] Fri, 28 January 2011 08:35 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
JoseB wrote on Fri, 28 January 2011 02:24

Hello
How can i convert utf-8 String variable in order to pass it to the strcmp() C++ function?

Thank you

JoseB

Hello JoseB

Could you indicate more details?.


Best regards
Iñaki
Re: How to convert utf-8 to (strcmp type)? [message #30906 is a reply to message #30904] Fri, 28 January 2011 10:16 Go to previous messageGo to next message
JoseB is currently offline  JoseB
Messages: 37
Registered: March 2009
Member
Basically I have a upp GUI app and a command line program which is called from that upp application. I want to pass it an argument with is a string or better a char * array. Internally this char * array will be used by strcmp.

JoseB

[Updated on: Fri, 28 January 2011 10:17]

Report message to a moderator

Re: How to convert utf-8 to (strcmp type)? [message #30909 is a reply to message #30906] Fri, 28 January 2011 10:22 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Do you want to convert it to a legacy encoding? strcmp will work for equality test with utf-8, but not with comparison.
Re: How to convert utf-8 to (strcmp type)? [message #30941 is a reply to message #30909] Fri, 28 January 2011 23:41 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello JoseB

I do not understand well the question but, if you require to pass a String to an API function you would have to do a ToSystemCharset().

For example, in Functions4U/FUnctios4U.cpp ReadOnly() function:

- In Windows, GetFileAttributesW() and SetFileAttributesW() require a ToSystemCharsetW().

- In POSIX, stat() and chmod() require a ToSystemCharset().


Best regards
Iñaki
Re: How to convert utf-8 to (strcmp type)? [message #30963 is a reply to message #30909] Sun, 30 January 2011 12:49 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
cbpporter wrote on Fri, 28 January 2011 04:22

Do you want to convert it to a legacy encoding? strcmp will work for equality test with utf-8, but not with comparison.


Actually, it will work for comparison as well, only the results might not be what you have expected...

Anyway, the same is true for 'legacy encoding'. The correct comparison depends on language rules; you ought to use LanguageInfo::Compare to get correct results, but it is now implemented only for Czech language and even that is not a full implementation of rules...

(That said, there is some default implementation in int DefaultLanguageCompare that would probably work reasonably well for most Latin based languages).


Mirek
Previous Topic: How to maximize printing area of the RichEdit Ctrl? [SOLVED]
Next Topic: Main frame dlg: How to store last dimension and position?
Goto Forum:
  


Current Time: Fri Apr 19 16:21:48 CEST 2024

Total time taken to generate the page: 0.02749 seconds