[redland-dev] Unicode retrieval librdf_node_to_string

Dave Beckett dave at dajobe.org
Wed Jul 9 03:51:58 BST 2008


Terance Brown wrote:
> I am trying to retrieve a unicode string using librdf_node_to_string 
> passing the node pointer into the function.
> 
> However, I am getting back a messed up string:
> 
>  
> 
> Expected return:   [!+'#[]Ü¥ƒ&,;
> 
>  
> 
> What I am getting: [!+’#[]Ü¥ƒ&,;

Hard to tell what that is given the encodings of email systems and
transcoding.  It should be UTF-8 out because that's what redland uses
for everything; it doesn't change encodings in either direction.

Also if you are not calling this from C (you don't say), there may
be another layer of software (SWIG + the script language)

> Can anybody help?  Does librdf_node_to_string handle Unicode?   I know 
> the source where I am retrieving the string is good.

That function really mostly for debugging since it adds punctuation
like '[' and ']' around URIs.

More likely you'll use
http://librdf.org/docs/api/redland-node.html#librdf-node-get-literal-value-as-counted-string
for example, when you know it's a literal
http://librdf.org/docs/api/redland-node.html#librdf-node-is-literal

i.e.
   if(librdf_node_is_literal(n)) {
     size_t len;
     string=librdf_node_get_literal_value_as_counted_string(n, &len);
     ... do something ...
   }

which is actually what librdf_node_to_string()
via librdf_node_to_counted_string() essentially does (but more efficiently)


Please provide a small code example and file a bug on bugs.librdf.org

Thanks

Dave


More information about the redland-dev mailing list