<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"MS Gothic";
panose-1:2 11 6 9 7 2 5 8 2 4;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"\@MS Gothic";
panose-1:2 11 6 9 7 2 5 8 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style>
</head>
<body lang="EN-GB" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Those two values are exactly the same. Lists of integers representing codepoints and strings are two ways of representing the same value. Reading back with file:consult should reproduce exactly the
same values.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">$ erl<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Erlang/OTP 23 [erts-11.1.5] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [hipe] [dtrace]<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Eshell V11.1.5 (abort with ^G)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">1> {"cn",[28450]} =:= {"cn","</span><span lang="EN-US" style="font-family:"MS Gothic";mso-fareast-language:EN-US">漢</span><span style="mso-fareast-language:EN-US">"}.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">true<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">2> io:format("~tp.\n",[{"cn","</span><span lang="EN-US" style="font-family:"MS Gothic";mso-fareast-language:EN-US">漢</span><span style="mso-fareast-language:EN-US">"}]).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">{"cn",[28450]}.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">ok<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">If you’re asking if you can make io:format print the string representation rather than list one for high-codepoint characters, the answer is you can, by starting the VM in Unicode mode with +pc unicode
flag:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">$ erl +pc unicode<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Erlang/OTP 23 [erts-11.1.5] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [hipe] [dtrace]<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Eshell V11.1.5 (abort with ^G)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="PL" style="mso-fareast-language:EN-US">1> io:format("~tp.\n",[{"cn","</span><span lang="EN-US" style="font-family:"MS Gothic";mso-fareast-language:EN-US">漢</span><span lang="PL" style="mso-fareast-language:EN-US">"}]).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">{"cn","</span><span lang="EN-US" style="font-family:"MS Gothic";mso-fareast-language:EN-US">漢</span><span style="mso-fareast-language:EN-US">"}.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">ok<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Michał.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">erlang-questions <erlang-questions-bounces@erlang.org> on behalf of Oliver Bollmann <oliver.bollmann@t-online.de><br>
<b>Date: </b>Tuesday, 26 January 2021 at 22:52<br>
<b>To: </b>Erlang-Questions Questions <erlang-questions@erlang.org><br>
<b>Subject: </b>Write Term to File<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">How can i write term to file, for later using in file:consult?<br>
<br>
I do:<br>
<br>
R = io_lib:format("~tp.",[{"cn","<span style="font-family:"MS Gothic"">漢</span>"}]),<br>
file:write_file(FileName,R)<br>
<br>
But this gives:<br>
<br>
{"cn",[28450]}.<br>
<br>
I need:<br>
<br>
{"cn","<span style="font-family:"MS Gothic"">漢</span>"}.<br>
<br>
Any hints?<br>
<br>
-- <br>
Grüße<br>
Oliver Bollmann<o:p></o:p></p>
</div>
</div>
</body>
</html>