special-characterskdb+

How to treat special character when casting string kdb


When casting a value to a string (via "string" keyword)

 Ex.
 t:([]stuff:`a`b`c)
 select string stuff from t 
 

Adds a weird special character before final 0a when calling from k function (via C client)

 0x0180

What is this ? What is best way of handling it ? Is there anyway to get a string without this special character ?

 stuff,more
 a,1.2�
 b,2.3�
 c,3.4�

Solution

  • Thought I would come back and answer this question years later, because solution is simple but can be tricky to see.

    The source of the problem , where the special character came from , indeed had to do with the kdb C api and datatype conversion semantics...

    On a query with a long list of columns, it was a matter of casting a column in the select statement using $ to perform the cast directly on the column. I don't remember the column value type, I think it was a boolean to int or something silly like that, but it had to be cast explicitly from column source type to what was expected by the C api. Example

    select col1, col2, "i"$someFlag, col3, etc from ... 
    

    Because C api couldn't swallow it correctly without that cast.