[erlang-questions] Jinterface OtpErlangBinary utf-8 double encoding

Carl-Johan Kjellander <>
Wed Dec 4 15:20:58 CET 2013


Ok, it is just a display thing in R15B.

()67> <<"Föö"/utf8>>.
<<"Föö">>
()68> <<"Föö">>.
<<"Föö">>

I thought the latter was utf-8 but probably not then, but the crazy
unicode-list-thingee.

/cjk



On Wed, Dec 4, 2013 at 3:10 PM, Carl-Johan Kjellander <
> wrote:

> ()58> <<_:8, A1/utf8, A2/utf8>> = <<"Föö">>.
> ** exception error: no match of right hand side value <<"Föö">>
>
> So what is the correct way of seeing it in the shell? Should I see it as
> the correct character or the utf-8 encoded ones?
>
> /cjk
>
>
> On Wed, Dec 4, 2013 at 2:57 PM, Dmitry Kolesnikov <>wrote:
>
>> Hello,
>>
>> This is correct UTF8 binary.
>>
>> unicode:characters_to_list(B).
>> "Föö"
>>
>> <<_:8, A1/utf8, A2/utf8>> = <<"Föö">>.
>> A1 = 246
>>
>> - Dmitry
>>
>> On Dec 4, 2013, at 3:15 PM, Carl-Johan Kjellander <
>> > wrote:
>>
>> I’m having utf-8 double encoding issues when sending binaries between
>> Java and Erlang.
>>
>>         java.lang.String foo = new java.lang.String("Föö");
>>         record[2] = new OtpErlangBinary(foo.getBytes());
>>
>> But of course that comes back as <<"Föö">> to my erlang node.
>>
>> Anyone have an idea why? Or how to fix? I'm compiling the java code with
>> -encoding UTF-8 and using Erlang R15B (erts-5.9).
>>
>> /cjk
>>
>>
>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20131204/fcb0d10d/attachment.html>


More information about the erlang-questions mailing list