Mar 30, 2011 at 7:23pm UTC
I am comparing two multibyte characters in two different platforms having different LC_CTYPE variables, they are returning different values.
One of the variable is sigma initialised to "\317\203"
and the other one is empty string i.e, ""
Below is the scenario of the two platforms:
In AIX:
LC_CTYPE="en_GB"
In Linux:
LC_CTYPE="en_US.UTF-8"
So, what could be the reason of a function returning different values in these two platforms ?
Mar 30, 2011 at 10:52pm UTC
Have you looked at the code in a debugger to see what the comparison is doing?
Mar 31, 2011 at 7:57am UTC
comparison is calculating the length of each char and then substracting one from another i.e,
cmpChar=len(sigma) - len ("")
For calculating length mbrlen function is used which is actually getting affected by different locales.
How should i proceed to get the same value in both platforms. Please suggest
Mar 31, 2011 at 6:58pm UTC
From the man page:
NOTES
The behavior of mbrlen() depends on the LC_CTYPE category of the cur-
rent locale.
With LC_CTYPE set to "en_GB" (a non-UTF locale) on any implementation, the string length will be the number of bytes used to encode all of the characters rather than the number of characters in the string.