cancel
Showing results for 
Search instead for 
Did you mean: 

Unicode character conversion issue

Denakaran
New Contributor III

Hi, 

     While i was trying to convert the unicode character of ô it is showing a different number.

q)`$`char$147

q)`$`char$244
`⌠
I could see the ASCII value for ô is 244 but when i try it in the q terminal it is showing a different result as mentioned above. Also you could see the value of 147 gives me the expected result as ô.  I am not sure what is happening behind this. 

1 ACCEPTED SOLUTION

rocuinneagain
Contributor III
Contributor III

Most modern shells will be UTF-8 encoded rather than ASCII.

kdb+ is storing the information correctly - it is just being displayed differently than you expect.

On my machine:

$ locale
LANG=C.UTF-8
LANGUAGE=
LC_CTYPE="C.UTF-8"
LC_NUMERIC="C.UTF-8"
LC_TIME="C.UTF-8"
LC_COLLATE="C.UTF-8"
LC_MONETARY="C.UTF-8"
LC_MESSAGES="C.UTF-8"
LC_PAPER="C.UTF-8"
LC_NAME="C.UTF-8"
LC_ADDRESS="C.UTF-8"
LC_TELEPHONE="C.UTF-8"
LC_MEASUREMENT="C.UTF-8"
LC_IDENTIFICATION="C.UTF-8"
LC_ALL=

 

UTF-8 encoding for ô is 0xC3 0xB4

Testing this in kdb+

q)`char$0xC3B4
"\303\264"
q)`$`char$0xC3B4
`ô

 

For your shell to print the extended ASCII table characters you will need to make some changes outside of kdb+.

 

View solution in original post

2 REPLIES 2

rocuinneagain
Contributor III
Contributor III

Most modern shells will be UTF-8 encoded rather than ASCII.

kdb+ is storing the information correctly - it is just being displayed differently than you expect.

On my machine:

$ locale
LANG=C.UTF-8
LANGUAGE=
LC_CTYPE="C.UTF-8"
LC_NUMERIC="C.UTF-8"
LC_TIME="C.UTF-8"
LC_COLLATE="C.UTF-8"
LC_MONETARY="C.UTF-8"
LC_MESSAGES="C.UTF-8"
LC_PAPER="C.UTF-8"
LC_NAME="C.UTF-8"
LC_ADDRESS="C.UTF-8"
LC_TELEPHONE="C.UTF-8"
LC_MEASUREMENT="C.UTF-8"
LC_IDENTIFICATION="C.UTF-8"
LC_ALL=

 

UTF-8 encoding for ô is 0xC3 0xB4

Testing this in kdb+

q)`char$0xC3B4
"\303\264"
q)`$`char$0xC3B4
`ô

 

For your shell to print the extended ASCII table characters you will need to make some changes outside of kdb+.

 

 Excellent thanks, that helps.