views:

423

answers:

2

Hello,

I'm playing a bit with erlang and the distributed db Mnesia.

One of the first problem I'm facing is the incompatibilty beetween the 'int list' strings of erlang and .Net UTF-8 strings.

Is there any good conversion library?

Thanks

+1  A: 

As far as I have seen, erlang uses UTF32, so using System.Text.Encoding.UTF32 might do the trick to get the ints for the list, then you need to create the list from those. Not tested though.

The following snippet may help (it creates an array of unicode ints which should match the ones expected for the erlang list):

public static int[] GetIntsForString(string source) {
 byte[] data = System.Text.Encoding.UTF32.GetBytes(source);
 int[] result = new int[source.Length];
 for (int i = 0; i < source.Length; i++) {
  result[i] = BitConverter.ToInt32(data, i*4);
 }
 return result;
}
Lucero
Do you have any example?
Luca Martinetti
Does the one added in the edit help, or is there something else you need help with?
Lucero
+3  A: 

The new R13B release of Erlang has better support for unicode.

The new Unicode module is documented here and the Unicode support implemented is described in the EEP 10 (Erlang Enhancement Proposal 10).

Gordon Guthrie