<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic UTF-8 and alternative to $hex. format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/UTF-8-and-alternative-to-hex-format/m-p/812026#M320356</link>
    <description>&lt;P&gt;Here the first character is 56, the second one is C3A9, the third one is 72 and the fourth one is 6F:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sasondemand.JPG" style="width: 277px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/71210i5972E1E48EDFA6FA/image-size/large?v=v2&amp;amp;px=999" role="button" title="sasondemand.JPG" alt="sasondemand.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do we know that the first character is not 56C3 for example?&lt;/P&gt;
&lt;P&gt;Is there a new format or feature which would allow to identify explicitely each character?&lt;/P&gt;
&lt;P&gt;Eg. get a value like 56-C3A9-72-6F in a similar way as the e8601da format as alternative to b8601da format for ISO dates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This would be useful as this kind of code helps identifying specific characters... to replace them.&lt;/P&gt;
&lt;P&gt;I've seen the kpropdata function but not tested it. It could cover most of the common situations but if a format solution exists, it would be good to know about it.&lt;/P&gt;</description>
    <pubDate>Sun, 08 May 2022 18:38:59 GMT</pubDate>
    <dc:creator>xxformat_com</dc:creator>
    <dc:date>2022-05-08T18:38:59Z</dc:date>
    <item>
      <title>UTF-8 and alternative to $hex. format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/UTF-8-and-alternative-to-hex-format/m-p/812026#M320356</link>
      <description>&lt;P&gt;Here the first character is 56, the second one is C3A9, the third one is 72 and the fourth one is 6F:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sasondemand.JPG" style="width: 277px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/71210i5972E1E48EDFA6FA/image-size/large?v=v2&amp;amp;px=999" role="button" title="sasondemand.JPG" alt="sasondemand.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do we know that the first character is not 56C3 for example?&lt;/P&gt;
&lt;P&gt;Is there a new format or feature which would allow to identify explicitely each character?&lt;/P&gt;
&lt;P&gt;Eg. get a value like 56-C3A9-72-6F in a similar way as the e8601da format as alternative to b8601da format for ISO dates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This would be useful as this kind of code helps identifying specific characters... to replace them.&lt;/P&gt;
&lt;P&gt;I've seen the kpropdata function but not tested it. It could cover most of the common situations but if a format solution exists, it would be good to know about it.&lt;/P&gt;</description>
      <pubDate>Sun, 08 May 2022 18:38:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/UTF-8-and-alternative-to-hex-format/m-p/812026#M320356</guid>
      <dc:creator>xxformat_com</dc:creator>
      <dc:date>2022-05-08T18:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: UTF-8 and alternative to $hex. format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/UTF-8-and-alternative-to-hex-format/m-p/812030#M320357</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data  _null_;
  text = "12ŻÓŁĆ34";
  do i = 1 to klength(text);
    x = ksubstr(text,i,1);
    t = putc(x,cats("hex",length(x)*2,"."));
    put t @@;
  end;
  put;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;log shows:&lt;/P&gt;
&lt;PRE&gt;1    data  _null_;
2      text = "12ŻÓŁĆ34";
3      do i = 1 to klength(text);
4        x = ksubstr(text,i,1);
5        t = putc(x,cats("hex",length(x)*2,"."));
6        put t @@;
7      end;
8      put;
9    run;

31 32 C5BB C393 C581 C486 33 34
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Sun, 08 May 2022 20:08:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/UTF-8-and-alternative-to-hex-format/m-p/812030#M320357</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2022-05-08T20:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: UTF-8 and alternative to $hex. format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/UTF-8-and-alternative-to-hex-format/m-p/812031#M320358</link>
      <description>&lt;P&gt;You can also just build yourself a format:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc FCMP outlib=work.f.p;
  function myHex(text $) $;
    length ret $ 32767;
    do i = 1 to klength(text);
      x = ksubstr(text,i,1);
      ret = catx("-", ret, putc(x,cats("hex",length(x)*2,".")));
    end;
    return(ret);
  endsub;
run;

options cmplib=work.f;

proc format;
  value $ myHex (default=200)
  other = [myHex()]
  ;
run;

data  _null_;
  text = "12ŻÓŁĆ34";
  put text $myHex.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[EDIT] one more approach, more "readable"&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc FCMP outlib=work.f.p;
  function myHex(text $) $;
    length ret $ 32767 x $ 4 t $ 8;
    do i = 1 to klength(text);
      x = ksubstr(text, i, 1);

      select(length(x));
        when (1)  t = put(x, $hex2.);
        when (2)  t = put(x, $hex4.);
        when (3)  t = put(x, $hex6.);
        otherwise t = put(x, $hex8.);
      end;

      ret = catx("-", ret, t);
    end;
    
    return(ret);
  endsub;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Sun, 08 May 2022 20:30:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/UTF-8-and-alternative-to-hex-format/m-p/812031#M320358</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2022-05-08T20:30:49Z</dc:date>
    </item>
  </channel>
</rss>

