>, B = <<"حیدری"/utf8>>, how can i concat ...">

How to execute two utf8 lines in erlang?

I have two variables as shown below:

A = <<"سعید"/utf8>>,
B = <<"حیدری"/utf8>>,

how can i concat Aand B?

C = <<A/utf8, B/utf8>>.

the line above returns exception error: bad argument

+4
source share
1 answer

utf8- it's just coding. It is binary like any other binary:

1> A = <<"سعید"/utf8>>,
1> B = <<"حیدری"/utf8>>,
1> C = <<A/bytes, B/bytes>>.
<<216,179,216,185,219,140,216,175,216,173,219,140,216,175,
  216,177,219,140>>
2> io:put_chars([C, $\n]).
سعیدحیدری
ok

PS: The result is shown in reverse order due to web browser behavior. It appears in the correct order on the console.

+7
source

Source: https://habr.com/ru/post/1684967/


All Articles