<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.0.4630.0">
<TITLE>C# binding encoding problem</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->

<P><FONT SIZE=2 FACE="Verdana">Hi Redlanders,</FONT>
</P>

<P><FONT SIZE=2 FACE="Verdana">I have been taking my first steps into Redland using Chris Pointon's VC++ project and Cesar Lopez Nataren's C# binding. I have got Redland to compile and have made a simple C# app for loading RDF and making RDQL queries. However I am having some problems with text encoding.</FONT></P>

<P><FONT SIZE=2 FACE="Verdana">Firstly I had to make changes to the C# wrapper regarding passing strings between managed and unmanaged code. I have had to change all IntPtr pointer = Marshal.StringToHGlobalAuto(aString); lines to IntPtr pointer = Marshal.StringToHGlobalAnsi(aString); and string aString = Marshal.PtrToStringAuto(pointer); lines to string aString = Marshal.PtrToStringAnsi(pointer);.</FONT></P>

<P><FONT SIZE=2 FACE="Verdana">Otherwise any calls that pass strings to or return strings from librdf do not work.</FONT>
</P>

<P><FONT SIZE=2 FACE="Verdana">For example, without these changes, stepping through the C code I notice that if I create a &quot;rdfxml&quot; parser, the line:</FONT>

<BR><FONT SIZE=2 FACE="Verdana">if(!strcmp(syntax_name, &quot;rdfxml&quot;)) { ...</FONT>

<BR><FONT SIZE=2 FACE="Verdana">in</FONT>

<BR><FONT SIZE=2 FACE="Verdana">librdf_parser_raptor_constructor() fails.</FONT>
</P>

<P><FONT SIZE=2 FACE="Verdana">However with the string marshalling changes I get various text encoding problems. For example when I parse my FOAF file [1], loading from URL with librdf_parser_parse_into_model(), and stream out the triples, all my buddies with latin-1 characters come out wrong. Leandro Mariano López comes out as Leandro Mariano López!</FONT></P>

<P><FONT SIZE=2 FACE="Verdana">Also, if I pass my FOAF as a string to librdf_parser_parse_string_into_model(), it loads all triples up to the first with a latin-1 character then stops. This and all subsequent triples are not parsed.</FONT></P>

<P><FONT SIZE=2 FACE="Verdana">Am I doing something wrong compiling Redland? Or is it something on the .Net side?</FONT>
</P>

<P><FONT SIZE=2 FACE="Verdana">I am using .Net 1.1 on Windows 2003 and compiling Redland with VC++ 6.</FONT>
</P>

<P><FONT SIZE=2 FACE="Verdana">[Please be gentle, I am a complete C newbie ;-)]</FONT>
</P>

<P><FONT SIZE=2 FACE="Verdana">Regards,</FONT>

<BR><FONT SIZE=2 FACE="Verdana">Victor Lindesay</FONT>
</P>

<P><FONT SIZE=2 FACE="Verdana">[1]</FONT>

<BR><A HREF="http://www.schemaweb.info/foaf/vlindesay.xml"><U><FONT COLOR="#0000FF" SIZE=2 FACE="Verdana">http://www.schemaweb.info/foaf/vlindesay.xml</FONT></U></A>
</P>
<BR>
<BR>
<BR>

</BODY>
</HTML>