www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Changing to UTF-8

reply jicman <jicman_member pathlink.com> writes:
Greetings!

Ok folks, I am sorry, but I have not been able to get UTF-8 to work.  So, let us
imagine that I have a subrouting that returns a bunch of XML that is non-UTF-8
to a string,

char[] str = GetNonUTF8Data();

How do I change str to UTF-8 data?  Any help would be greatly appreciate it.

thanks.

jic
Mar 24 2005
next sibling parent reply "Ben Hinkle" <ben.hinkle gmail.com> writes:
 How do I change str to UTF-8 data?  Any help would be greatly appreciate 
 it.
There are two options: 1) the ICU binding in mango http://dsource.org/projects/mango/ 2) the iconv binding that I can't seem to find anywhere but I remember seeing... anyone know where the iconv binding is? (ps - I wish we had an updated community links/libs page...)
Mar 24 2005
parent reply Manfred Hansen <manfred toppoint.de> writes:
Ben Hinkle wrote:

 How do I change str to UTF-8 data?  Any help would be greatly appreciate
 it.
There are two options: 1) the ICU binding in mango http://dsource.org/projects/mango/ 2) the iconv binding that I can't seem to find anywhere but I remember seeing... anyone know where the iconv binding is? (ps - I wish we had an updated community links/libs page...)
I have try to collect some links in a database. http://www.steinmole.de/d_lib You can search for iconv. Manfred
Mar 25 2005
parent reply J C Calvarese <jcc7 cox.net> writes:
Manfred Hansen wrote:
 Ben Hinkle wrote:
 
 
How do I change str to UTF-8 data?  Any help would be greatly appreciate
it.
There are two options: 1) the ICU binding in mango http://dsource.org/projects/mango/ 2) the iconv binding that I can't seem to find anywhere but I remember seeing... anyone know where the iconv binding is? (ps - I wish we had an updated community links/libs page...)
I think I found the iconv binding: http://www.algonet.se/~afb/d/libiconv.d (from http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/17913) And a related thread that seemed to devolve into licensing issues: http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/13095
 I have try to collect some links in a database.
 http://www.steinmole.de/d_lib
Cool idea.
 You can search for iconv.
 
 Manfred
I think you meant this: http://www.steinmole.de/d_lib/start.cgi Looks good. I hope you don't mind that I added it to http://www.prowiki.org/wiki4d/wiki.cgi?MoreLinks -- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/
Mar 25 2005
parent Manfred Hansen <manfred toppoint.de> writes:
J C Calvarese wrote:

 Manfred Hansen wrote:
 Ben Hinkle wrote:
 
 
How do I change str to UTF-8 data?  Any help would be greatly appreciate
it.
There are two options: 1) the ICU binding in mango http://dsource.org/projects/mango/ 2) the iconv binding that I can't seem to find anywhere but I remember seeing... anyone know where the iconv binding is? (ps - I wish we had an updated community links/libs page...)
I think I found the iconv binding: http://www.algonet.se/~afb/d/libiconv.d (from http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/17913) And a related thread that seemed to devolve into licensing issues: http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/13095
 I have try to collect some links in a database.
 http://www.steinmole.de/d_lib
Cool idea.
The idea came in my mind from Ruby Application Archive. http://raa.ruby-lang.org/ During insert the links in the database, i was surprised how many libraries and tools there are for D.
 
 You can search for iconv.
 
 Manfred
I think you meant this: http://www.steinmole.de/d_lib/start.cgi
Yes that is OK.
 
 Looks good.
The most work was to deal with the special character å, ö and so on.
 I hope you don't mind that I added it to 
 http://www.prowiki.org/wiki4d/wiki.cgi?MoreLinks
 
No problem. Manfred
Mar 26 2005
prev sibling parent "Regan Heath" <regan netwin.co.nz> writes:
On Fri, 25 Mar 2005 03:56:03 +0000 (UTC), jicman  
<jicman_member pathlink.com> wrote:
 Greetings!

 Ok folks, I am sorry, but I have not been able to get UTF-8 to work.   
 So, let us
 imagine that I have a subrouting that returns a bunch of XML that is  
 non-UTF-8
 to a string,

 char[] str = GetNonUTF8Data();
Step 1, don't use char[] to store non UTF-8 data. Use byte[]. eg. byte[] raw = GetNonUTF8Data();
 How do I change str to UTF-8 data?  Any help would be greatly appreciate  
 it.
Step 2, find/write a routine to convert from your encoding X into UTF-8 and call it. Ben has suggested some libraries that will do it. Alternately, depending on X, it might be easy/possible to write a routine yourself. Regan
Mar 25 2005