2
$\begingroup$

Consider the function:

unicode[numericLetters_List]:=StringJoin@Reverse@Cases[numericLetters,x_:>If[x!=" ","\:"<>x,x]];

now

unicode[{"06af", "0648", "0644"}]

prints "\\:0644\\:0648\\:06af"

instead of "\:0644\:0648\:06af"

How do i fix this?

$\endgroup$
3
  • $\begingroup$ Actually, you have already obtained what you desire, to see which, run unicode[{"06af", "0648", "0644"}] // FullForm. $\endgroup$ Commented Nov 22, 2018 at 11:07
  • $\begingroup$ Actually it still shows \\: while \: would have converted the successive characters into a corresponding Unicode character. $\endgroup$ Commented Nov 22, 2018 at 11:25
  • $\begingroup$ Then I GUESS this is what you want: FromCharacterCode[FromDigits[#, 16]] & /@ Reverse @ {"06af", "0648", "0644"}. You may use StringJoin afterwards. $\endgroup$ Commented Nov 22, 2018 at 11:54

1 Answer 1

3
$\begingroup$

I guess that you might want to get the characters to be shown, then you might need FromCharacterCode. So I suggest to define your unicode function in this way:

unicode[code_List] := FromCharacterCode[FromDigits[#, 16]] & /@ Reverse@code // StringJoin

unicode[{"06af", "0648", "0644"}]
"لوگ"
$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.