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
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
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 int
s 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;
}
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).