B
Bart Rider
Hi all,
last week i had to write a little homework program like open
a file and count all characters present in this file. I did it
using a counting array of size 256 and increasing the specific
chars position by one, if i've read that character from the
file.
The file itself was opened via a FileReader/BufferedReader and
the lines were read by readLine()
Now i observed the following. The character 'ä' stored in the
char variable c and used to access the counting array:
countingArray[c]++
caused no problems on windows/linux computers, but on macs,
where the value 8240 (0x2030) was assigned with this char.
It seems to me, that char on mac computers is 16bit wide.
Is this true?
Using a mac even a double cast like
countingArray[(char)(int)c]++
did not work. And (c & 0xFF) was no option either, because now
i would match the 'ä' to '0' (0x30).
I solved the problem by using a try-catch-block and counting
'other' characters through it.
Best regards,
Bart
last week i had to write a little homework program like open
a file and count all characters present in this file. I did it
using a counting array of size 256 and increasing the specific
chars position by one, if i've read that character from the
file.
The file itself was opened via a FileReader/BufferedReader and
the lines were read by readLine()
Now i observed the following. The character 'ä' stored in the
char variable c and used to access the counting array:
countingArray[c]++
caused no problems on windows/linux computers, but on macs,
where the value 8240 (0x2030) was assigned with this char.
It seems to me, that char on mac computers is 16bit wide.
Is this true?
Using a mac even a double cast like
countingArray[(char)(int)c]++
did not work. And (c & 0xFF) was no option either, because now
i would match the 'ä' to '0' (0x30).
I solved the problem by using a try-catch-block and counting
'other' characters through it.
Best regards,
Bart