LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Looking for C/C++ unicode related programming tutorial (https://www.linuxquestions.org/questions/programming-9/looking-for-c-c-unicode-related-programming-tutorial-440728/)

graemef 05-11-2006 06:30 AM

Quote:

Originally Posted by George2
Why comparison of the characters with the same length is faster than variable-length characters? I think it depends on how we implement the comparison algorithm.

If you are doing a comparison with variable-length characters then you will need to do two checks, per character in the string. First what is the character length, then how do they compare with each other. Whereas if you are using fixed-length characters you need to do just a single check, per character in the string, namely the comparison.

The actual comparison rules are locale defined, and may mix the single byte and double byte characters. for example the character a can also come with accents - grace, acute umlaut. Different languages will have different comparison rules, for some it will bundle 'a' along with all its accented variants other locales will have all the un-accented characters followed by accented characters. So to do the comparison requires to lookup the locale defined order on a table and then convert this to a number which makes the comparison easier but to get the table in the first place requires the underlying data structure to be - well, structured - of a fixed width.

I realise that in trying to condense the description I may have made it more confusing so feel free to ask further questions.

graeme.


All times are GMT -5. The time now is 05:53 AM.