<?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 Re: best practices around special characters in JSL? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/best-practices-around-special-characters-in-JSL/m-p/214881#M42966</link>
    <description>Thanks!</description>
    <pubDate>Wed, 26 Jun 2019 18:45:21 GMT</pubDate>
    <dc:creator>hardner</dc:creator>
    <dc:date>2019-06-26T18:45:21Z</dc:date>
    <item>
      <title>best practices around special characters in JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/best-practices-around-special-characters-in-JSL/m-p/214000#M42788</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;example="blah blah Width = 25.0 �m ..some more stuff";

widthtext=regex(example,"Width\s=\s+\d+[.]\d+\s[\w?�]m");&lt;BR /&gt;&lt;BR /&gt;widthtext=regex(example,"Width\s=\s+\d+[.]\d+\s[\w?\x{FFFD}]m");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Sorry this is less a very specific problem that a general issue I'm looking for recommendations on as I've had this issue in different contexts.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this specific example I'm using loadtextfile() to get some text that I need to parse and that text can have special characters.&amp;nbsp; here I'm using the variable "example" to show what that looks like to JMP -it has replaced something with a "mystery" symbol. (in case it doesn't continue to show up here it's a black diamond with a question mark in it.) I know that symbol is unicode FFFD (and I know in this case that originally it was a mu, for microns though not sure what particular encoding it had that JMP couldn't work out).&amp;nbsp; I know there are options in the preferences for the charset to use when loading the text file so maybe I could trial and error until this really shows up as a mu.&amp;nbsp; But since my script is looking through a lot of different files I'm not sure I can set a preference that will not have this issue of failing to work out a character and in any case my issue is really with how to talk about any special character in my script, not with having "mystery" instead of mu.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;In the example above I pasted in the character as it was shown in the JMP log in order to have it in JSL (second line of code RegEx).&amp;nbsp; &amp;nbsp;That works.&amp;nbsp; &amp;nbsp;contains() works too with the special doodad pasted into it as an argument.&amp;nbsp; But when I save the JSL and reopen it the special character is replaced with ? and the code using the pasted symbol no longer works.&amp;nbsp; seemingly any special characters in JSL are at risk of getting lost.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My third line is fixing that for RegEx.&amp;nbsp; I can call out the character by number so it will run after opening&amp;nbsp; - on a case where instead of hardcoded example I open a text file and have those symbols in there. But what if I want to do any other string things?&amp;nbsp; so far I converted a contains() to a regex() but are there any other ways to use symbols in JSL?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've had similar issues around greek letters JMP uses in its reports (like a sigma).&amp;nbsp; I want to write code that tests for some text in the report but if I paste in the symbol the JSL will get replaced.&amp;nbsp; These are symbols JMP is choosing and using and yet I can't use them in my JSL robustly.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2019 20:26:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/best-practices-around-special-characters-in-JSL/m-p/214000#M42788</guid>
      <dc:creator>hardner</dc:creator>
      <dc:date>2019-06-20T20:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: best practices around special characters in JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/best-practices-around-special-characters-in-JSL/m-p/214071#M42798</link>
      <description>&lt;P&gt;The diamond-question mark is the Unicode replacement character.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;JMP prefers Unicode, but can guess other character sets with varying degrees of success.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;JMP also may try to preserve the character set of a file when it is re-saved, but if the file had byte sequences that are not valid in the input character set, they become the replacement character, and it will become the question mark in a non Unicode character set conversion. (I think some variation of this is what happened in your example.)&lt;/P&gt;
&lt;P&gt;It is possible you could select the right character set (preferences), and it is also possible the file is using mu from a non-Unicode character set while claiming to be a Unicode file with a Byte Order Mark.&lt;/P&gt;
&lt;P&gt;There are a number of web sites that make it fairly easy to get the Unicode hex data; I've used Windows Character Map here:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Unicode escape" style="width: 924px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/17851iD71EF12D533B516F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Unicode escape" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Unicode escape&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;(edit) If you open the file again, I'd suggest trying windows 1252 as a starting point. I think Load Text File has options for specifying the character set without using the preferences.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Set it back to Best Guess when done" style="width: 640px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/17852i2071EE7D07A057E6/image-size/large?v=v2&amp;amp;px=999" role="button" title="charset.png" alt="Set it back to Best Guess when done" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Set it back to Best Guess when done&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jun 2019 14:23:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/best-practices-around-special-characters-in-JSL/m-p/214071#M42798</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2019-06-21T14:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: best practices around special characters in JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/best-practices-around-special-characters-in-JSL/m-p/214861#M42951</link>
      <description>&lt;P&gt;Thanks!&amp;nbsp; the bit I was missing was how to talk about that in JSL outside of regex in a way that wouldn't get replaced in the JSL file and I see from your example this is how...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"\!UFFFD"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That raises a related question though about what the character is and it's not so much that I want JMP to find the right character set to open the file (whole other issue) but that I want to talk about the character as used by JMP in JSL and not have the JSL corrupted on closing and open the file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; In this case I looked up the character pretty easily and found a code that identified it and it worked in JMP. Say I have the character in JMP in the log (maybe JMP did find and report&amp;nbsp; a mu character or say it's the sigma JMP itself uses in a report -&amp;nbsp; for code that will parse some text I only care what JMP is using as the characters in that text )... is there any direct way to get a code like "UFFFD" for the character JMP is actually using?&amp;nbsp; &amp;nbsp; something like &lt;STRONG&gt;what_is_this_character("�")&lt;/STRONG&gt;.&amp;nbsp; When I keep having this issue I generally can see and copy and paste the character as used by JMP and that's the context in which I want to talk about it robustly in JSL.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2019 16:06:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/best-practices-around-special-characters-in-JSL/m-p/214861#M42951</guid>
      <dc:creator>hardner</dc:creator>
      <dc:date>2019-06-26T16:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: best practices around special characters in JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/best-practices-around-special-characters-in-JSL/m-p/214875#M42961</link>
      <description>&lt;P&gt;Yes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;x = "\!U266b";
Show( x ); // "♫"
y = Char To Blob( x, encoding = "utf-16be" );
Show( Hex( y ) ); // "266B"
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if you are seeing the Unicode replacement character (the question mark in a black diamond) then you may also have other characters that are being mapped to the replacement character. If possible, find the right character set to avoid the many-to-one problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There may be a more clever way than the snippet above. The CharToBlob function converts the character to a 16-bit big-endian Unicode representation, and the Hex function converts the blob to printable hex.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you don't specify the encoding charset for CharToBlob, it will default to UTF-8, and for this particular character, you'll get a 3-byte value,&amp;nbsp;"E299AB"&amp;nbsp;&lt;A href="https://www.fileformat.info/info/unicode/char/266b/index.htm" target="_blank" rel="noopener"&gt;fileformat.info page for BEAMED EIGHTH NOTES&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2019 17:40:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/best-practices-around-special-characters-in-JSL/m-p/214875#M42961</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2019-06-26T17:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: best practices around special characters in JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/best-practices-around-special-characters-in-JSL/m-p/214881#M42966</link>
      <description>Thanks!</description>
      <pubDate>Wed, 26 Jun 2019 18:45:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/best-practices-around-special-characters-in-JSL/m-p/214881#M42966</guid>
      <dc:creator>hardner</dc:creator>
      <dc:date>2019-06-26T18:45:21Z</dc:date>
    </item>
  </channel>
</rss>

