<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Webdialog to ruby encoding issue on OSX]]></title><description><![CDATA[<p dir="auto">I think I've read something about this a while ago, but can't find it anymore. If anyone has a link...?</p>
<p dir="auto">Anyway, I have an issue with string encoding in webdialog callbacks on OSX. When a string is passed as a parameter, ruby doesn't display special characters correctly.<br />
Like "ç" becomes "√ß".<br />
Every rb, html and js file is of course UTF-8 encoded. It breaks even if I try a <code> .force_encoding("utf-8")</code> on the returned string (in SU2014).</p>
<p dir="auto">It works fine on Windows 7.</p>
<p dir="auto">Any thought?</p>
]]></description><link>https://community.sketchucation.com/topic/146331/webdialog-to-ruby-encoding-issue-on-osx</link><generator>RSS for Node</generator><lastBuildDate>Fri, 09 Oct 2026 10:48:35 GMT</lastBuildDate><atom:link href="https://community.sketchucation.com/topic/146331.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 25 May 2014 20:54:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Webdialog to ruby encoding issue on OSX on Sun, 08 Jun 2014 21:30:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tt_su" aria-label="Profile: tt_su">@<bdi>tt_su</bdi></a> said:</p>
<blockquote>
<p dir="auto">So this <em>only</em> happen on OSX, not on Windows?</p>
</blockquote>
<p dir="auto">hi TT</p>
<p dir="auto">did you get a chance to run this on your mac?</p>
<p dir="auto">and did it confirm what I state, on your setup?</p>
<p dir="auto">john</p>
]]></description><link>https://community.sketchucation.com/post/1445236</link><guid isPermaLink="true">https://community.sketchucation.com/post/1445236</guid><dc:creator><![CDATA[driven]]></dc:creator><pubDate>Sun, 08 Jun 2014 21:30:23 GMT</pubDate></item><item><title><![CDATA[Reply to Webdialog to ruby encoding issue on OSX on Sat, 31 May 2014 13:33:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/driven" aria-label="Profile: driven">@<bdi>driven</bdi></a> said:</p>
<blockquote>
<p dir="auto">@ Steve<br />
do you think the two are unrelated?<br />
john</p>
</blockquote>
<p dir="auto">It's possible they have the same cause, but I am not sure how to prove that.</p>
<p dir="auto">The man page for the locale command says:</p>
<pre><code> LANG         Used as a substitute for any unset LC_* variable.  If LANG is unset, it will
              act as if set to "C".  If any of LANG or LC_* are set to invalid values, locale
              acts as if they are all unset.
</code></pre>
<p dir="auto">So the behavior you get is consistent with LANG not being set by SU when it launches a subshell.  Also, if you set ENV[LANG] to a specific locale such as "en_US.UTF-8" in the Ruby Console before doing the %x, the other variables all follow.</p>
<p dir="auto">So far as I can tell, SU doesn't launch a separate process for a WebDialog (at least I don't see one reported in Activity Monitor).  I don't know what environment a WebDialog gets...can it be read from javascript?</p>
<p dir="auto">Steve</p>
]]></description><link>https://community.sketchucation.com/post/1444351</link><guid isPermaLink="true">https://community.sketchucation.com/post/1444351</guid><dc:creator><![CDATA[slbaumgartner]]></dc:creator><pubDate>Sat, 31 May 2014 13:33:05 GMT</pubDate></item><item><title><![CDATA[Reply to Webdialog to ruby encoding issue on OSX on Fri, 30 May 2014 20:42:51 GMT]]></title><description><![CDATA[<p dir="auto">eval works great, thanks!</p>
]]></description><link>https://community.sketchucation.com/post/1444311</link><guid isPermaLink="true">https://community.sketchucation.com/post/1444311</guid><dc:creator><![CDATA[jiminy-billy-bob]]></dc:creator><pubDate>Fri, 30 May 2014 20:42:51 GMT</pubDate></item><item><title><![CDATA[Reply to Webdialog to ruby encoding issue on OSX on Fri, 30 May 2014 20:32:12 GMT]]></title><description><![CDATA[<p dir="auto">@ Steve<br />
do you think the two are unrelated?</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jiminy-billy-bob" aria-label="Profile: jiminy-billy-bob">@<bdi>jiminy-billy-bob</bdi></a> said:</p>
<blockquote>
<p dir="auto">Any thought on that?</p>
</blockquote>
<p dir="auto">if I eval it double quoted, I get <code> élan 勢い Schwung импульс</code></p>
<pre><code>    puts (eval('"' + param_fix + '"'))
</code></pre>
<p dir="auto">works in UI.messagebox that way as well.</p>
<p dir="auto">alternatively I wrote [so it is possible] a simple decode method by reversing the JS function back in ruby, it worked but i can't find it...</p>
<p dir="auto">john</p>
]]></description><link>https://community.sketchucation.com/post/1444307</link><guid isPermaLink="true">https://community.sketchucation.com/post/1444307</guid><dc:creator><![CDATA[driven]]></dc:creator><pubDate>Fri, 30 May 2014 20:32:12 GMT</pubDate></item><item><title><![CDATA[Reply to Webdialog to ruby encoding issue on OSX on Fri, 30 May 2014 12:52:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/driven" aria-label="Profile: driven">@<bdi>driven</bdi></a> said:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tt_su" aria-label="Profile: tt_su">@<bdi>tt_su</bdi></a> said:</p>
<blockquote>
<p dir="auto">So this <em>only</em> happen on OSX, not on Windows?</p>
</blockquote>
<p dir="auto">as far as I'm aware it's a mac thing...</p>
<p dir="auto">I think it's because the internal bash env locale defaults to "C" if not implicedly set</p>
</blockquote>
<pre><code>&gt; %x(locale)
&gt; LANG=
&gt; LC_COLLATE="C"
&gt; LC_CTYPE="C"
&gt; LC_MESSAGES="C"
&gt; LC_MONETARY="C"
&gt; LC_NUMERIC="C"
&gt; LC_TIME="C"
&gt; LC_ALL=
</code></pre>
<blockquote>
<p dir="auto">whereas same call in 'Terminal.app'</p>
</blockquote>
<pre><code>LANG="en_US"
&gt; LC_COLLATE="en_US.UTF-8"
&gt; LC_CTYPE="en_US.UTF-8"
&gt; LC_MESSAGES="en_US.UTF-8"
&gt; LC_MONETARY="en_US.UTF-8"
&gt; LC_NUMERIC="en_US.UTF-8"
&gt; LC_TIME="en_US.UTF-8"
&gt; LC_ALL="en_US.UTF-8"
</code></pre>
<blockquote>
<p dir="auto">because it is set...<br />
john</p>
</blockquote>
<p dir="auto">I think this is because SU does not set ENV["LANG"] when launching the subshell.</p>
<p dir="auto">Steve</p>
]]></description><link>https://community.sketchucation.com/post/1444255</link><guid isPermaLink="true">https://community.sketchucation.com/post/1444255</guid><dc:creator><![CDATA[slbaumgartner]]></dc:creator><pubDate>Fri, 30 May 2014 12:52:13 GMT</pubDate></item><item><title><![CDATA[Reply to Webdialog to ruby encoding issue on OSX on Fri, 30 May 2014 12:46:27 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/driven" aria-label="Profile: driven">@<bdi>driven</bdi></a> said:</p>
<blockquote>
<p dir="auto">post a snippet, and I'll run some checks...</p>
</blockquote>
<p dir="auto">Going back to your test <a href="http://sketchucation.com/forums/viewtopic.php?f" target="_blank" rel="noopener noreferrer nofollow ugc">here</a></p>
<p dir="auto">If you add</p>
<pre><code>Sketchup.active_model.layers.add param_fix
</code></pre>
<p dir="auto">in <code> @dlg2.add_action_callback("trans_L8_fix")</code></p>
<p dir="auto">The layer name is displayed <strong>"élan 勢い Schwung импульс"</strong> in Layers Panel, as it is a webdialog.<br />
But in Sketchup's layer window, it's displayed <strong>"\u00E9lan \u52E2\u3044 Schwung \u0438\u043C\u043F\u0443\u043B\u044C\u0441"</strong>, just like what's printed in the ruby console.</p>
<p dir="auto">Any thought on that?</p>
<p dir="auto">TT &gt; Yes, everything is set to UTF-8. Encoding, meta-tags</p>
]]></description><link>https://community.sketchucation.com/post/1444254</link><guid isPermaLink="true">https://community.sketchucation.com/post/1444254</guid><dc:creator><![CDATA[jiminy-billy-bob]]></dc:creator><pubDate>Fri, 30 May 2014 12:46:27 GMT</pubDate></item><item><title><![CDATA[Reply to Webdialog to ruby encoding issue on OSX on Thu, 29 May 2014 19:48:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tt_su" aria-label="Profile: tt_su">@<bdi>tt_su</bdi></a> said:</p>
<blockquote>
<p dir="auto">So this <em>only</em> happen on OSX, not on Windows?</p>
</blockquote>
<p dir="auto">as far as I'm aware it's a mac thing...</p>
<p dir="auto">I think it's because the internal bash env locale defaults to "C" if not implicedly set</p>
<pre><code>&gt; %x(locale)
LANG=
LC_COLLATE="C"
LC_CTYPE="C"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
</code></pre>
<p dir="auto">whereas same call in 'Terminal.app'</p>
<pre><code>LANG="en_US"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
</code></pre>
<p dir="auto">because it is set...<br />
john</p>
]]></description><link>https://community.sketchucation.com/post/1444199</link><guid isPermaLink="true">https://community.sketchucation.com/post/1444199</guid><dc:creator><![CDATA[driven]]></dc:creator><pubDate>Thu, 29 May 2014 19:48:58 GMT</pubDate></item><item><title><![CDATA[Reply to Webdialog to ruby encoding issue on OSX on Thu, 29 May 2014 09:05:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/driven" aria-label="Profile: driven">@<bdi>driven</bdi></a> said:</p>
<blockquote>
<p dir="auto">the <strong>third last</strong> post from the other thread has a rbz that shows the issue on a mac...<br />
<a href="http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=57074%26amp;start=30#p518959" target="_blank" rel="noopener noreferrer nofollow ugc">http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=57074%26amp;start=30#p518959</a></p>
</blockquote>
<p dir="auto">So this <em>only</em> happen on OSX, not on Windows?</p>
]]></description><link>https://community.sketchucation.com/post/1444129</link><guid isPermaLink="true">https://community.sketchucation.com/post/1444129</guid><dc:creator><![CDATA[tt_su]]></dc:creator><pubDate>Thu, 29 May 2014 09:05:16 GMT</pubDate></item><item><title><![CDATA[Reply to Webdialog to ruby encoding issue on OSX on Wed, 28 May 2014 22:39:01 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dan" aria-label="Profile: dan">@<bdi>dan</bdi></a> rathbun said:</p>
<blockquote>
<p dir="auto">Did someone file a bug report ?</p>
</blockquote>
<p dir="auto">I was going to but I got distracted by work and it's still on my endless todo list...</p>
<p dir="auto">john</p>
]]></description><link>https://community.sketchucation.com/post/1444080</link><guid isPermaLink="true">https://community.sketchucation.com/post/1444080</guid><dc:creator><![CDATA[driven]]></dc:creator><pubDate>Wed, 28 May 2014 22:39:01 GMT</pubDate></item><item><title><![CDATA[Reply to Webdialog to ruby encoding issue on OSX on Wed, 28 May 2014 22:24:55 GMT]]></title><description><![CDATA[<p dir="auto">Did someone file a bug report ?</p>
]]></description><link>https://community.sketchucation.com/post/1444075</link><guid isPermaLink="true">https://community.sketchucation.com/post/1444075</guid><dc:creator><![CDATA[Dan Rathbun]]></dc:creator><pubDate>Wed, 28 May 2014 22:24:55 GMT</pubDate></item><item><title><![CDATA[Reply to Webdialog to ruby encoding issue on OSX on Wed, 28 May 2014 21:44:04 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tt" aria-label="Profile: TT">@<bdi>TT</bdi></a></p>
<p dir="auto">the <strong>third last</strong> post from the other thread has a rbz that shows the issue on a mac...<br />
<a href="http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=57074%26amp;start=30#p518959" target="_blank" rel="noopener noreferrer nofollow ugc">http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=57074%26amp;start=30#p518959</a></p>
<p dir="auto">returns using 'get_element_value' have bad encoding regardless of html declarations, script encodings, etc...</p>
<p dir="auto">something is happening internally in SU that screws things up...</p>
<p dir="auto">try the rbz it's harmless...</p>
<p dir="auto">john</p>
]]></description><link>https://community.sketchucation.com/post/1444068</link><guid isPermaLink="true">https://community.sketchucation.com/post/1444068</guid><dc:creator><![CDATA[driven]]></dc:creator><pubDate>Wed, 28 May 2014 21:44:04 GMT</pubDate></item><item><title><![CDATA[Reply to Webdialog to ruby encoding issue on OSX on Wed, 28 May 2014 21:22:17 GMT]]></title><description><![CDATA[<p dir="auto">Btw, what is the source for this character?</p>
]]></description><link>https://community.sketchucation.com/post/1444061</link><guid isPermaLink="true">https://community.sketchucation.com/post/1444061</guid><dc:creator><![CDATA[tt_su]]></dc:creator><pubDate>Wed, 28 May 2014 21:22:17 GMT</pubDate></item><item><title><![CDATA[Reply to Webdialog to ruby encoding issue on OSX on Wed, 28 May 2014 21:21:34 GMT]]></title><description><![CDATA[<p dir="auto">Ditto on OSX:</p>
<p dir="auto"><img src="/uploads/imported_attachments/T1dL_2014-05-28_23h17_20.png" alt="2014-05-28_23h17_20.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">I think we need a full example of the error you get - packaged up as RBZ.</p>
]]></description><link>https://community.sketchucation.com/post/1444060</link><guid isPermaLink="true">https://community.sketchucation.com/post/1444060</guid><dc:creator><![CDATA[tt_su]]></dc:creator><pubDate>Wed, 28 May 2014 21:21:34 GMT</pubDate></item><item><title><![CDATA[Reply to Webdialog to ruby encoding issue on OSX on Wed, 28 May 2014 21:13:51 GMT]]></title><description><![CDATA[<p dir="auto">Is your HTML in UTF-8 and tagged with a UTF-8 meta tag so the HTML engine knows to use UTF8?<br />
I tried that ç character in SKUI and it renders fine:<br />
<img src="/uploads/imported_attachments/DaRd_2014-05-28_23h08_54.png" alt="2014-05-28_23h08_54.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">I'm not doing anything special, other than ensuring the my RB files are UTF-8 encoded, that my HTML files are UTF-8 encoded (with UTF-8 characterset META tag.)</p>
]]></description><link>https://community.sketchucation.com/post/1444058</link><guid isPermaLink="true">https://community.sketchucation.com/post/1444058</guid><dc:creator><![CDATA[tt_su]]></dc:creator><pubDate>Wed, 28 May 2014 21:13:51 GMT</pubDate></item><item><title><![CDATA[Reply to Webdialog to ruby encoding issue on OSX on Wed, 28 May 2014 19:27:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jiminy-billy-bob" aria-label="Profile: jiminy-billy-bob">@<bdi>jiminy-billy-bob</bdi></a> said:</p>
<blockquote>
<p dir="auto">The problem is that ruby reads the unicode as is, without converting to actual characters. I end up with layers called something like "\u00E9" in SU's layer window</p>
</blockquote>
<p dir="auto">are you single quoting it?</p>
<pre><code>&gt; "\u00E9"
é
&gt; '\u00E9'
\u00E9
&gt; %q(\u00E9)
\u00E9
&gt; %Q(\u00E9)
é
</code></pre>
<p dir="auto">or maybe use <code> .inspect</code>?</p>
<pre><code>"\u00E9".inspect
"é"
</code></pre>
<p dir="auto">else<br />
post a snippet, and I'll run some checks...</p>
<p dir="auto">I did write a ruby encode/decode, but didn't need it for what I was doing...</p>
<p dir="auto">I'll see if I kept it</p>
<p dir="auto">john</p>
]]></description><link>https://community.sketchucation.com/post/1444049</link><guid isPermaLink="true">https://community.sketchucation.com/post/1444049</guid><dc:creator><![CDATA[driven]]></dc:creator><pubDate>Wed, 28 May 2014 19:27:00 GMT</pubDate></item><item><title><![CDATA[Reply to Webdialog to ruby encoding issue on OSX on Wed, 28 May 2014 18:56:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jiminy-billy-bob" aria-label="Profile: jiminy-billy-bob">@<bdi>jiminy-billy-bob</bdi></a> said:</p>
<blockquote>
<p dir="auto">The problem is that ruby reads the unicode as is, without converting to actual characters.</p>
</blockquote>
<p dir="auto"><img src="https://community.sketchucation.com/assets/plugins/nodebb-plugin-emoji/emoji/android/2753.png?v=1787be8a233" class="not-responsive emoji emoji-android emoji--question" style="height:23px;width:auto;vertical-align:middle" title=":question:" alt="❓" /></p>
<p dir="auto">Is it execute_script being the issue? (Sorry, loooong thread - got confused.)</p>
]]></description><link>https://community.sketchucation.com/post/1444045</link><guid isPermaLink="true">https://community.sketchucation.com/post/1444045</guid><dc:creator><![CDATA[tt_su]]></dc:creator><pubDate>Wed, 28 May 2014 18:56:42 GMT</pubDate></item><item><title><![CDATA[Reply to Webdialog to ruby encoding issue on OSX on Wed, 28 May 2014 14:59:15 GMT]]></title><description><![CDATA[<p dir="auto">John, your solution works well when sending the string back to the webdialog. But in my case I'm trying to read the string inside ruby (actually change layers names).<br />
The problem is that ruby reads the unicode as is, without converting to actual characters. I end up with layers called something like "\u00E9" in SU's layer window (But it displays fine in my webdialog)</p>
<p dir="auto">I can't find a solution on google. Do you guys have any idea what I should do?</p>
]]></description><link>https://community.sketchucation.com/post/1444014</link><guid isPermaLink="true">https://community.sketchucation.com/post/1444014</guid><dc:creator><![CDATA[jiminy-billy-bob]]></dc:creator><pubDate>Wed, 28 May 2014 14:59:15 GMT</pubDate></item><item><title><![CDATA[Reply to Webdialog to ruby encoding issue on OSX on Tue, 27 May 2014 17:59:16 GMT]]></title><description><![CDATA[<p dir="auto">This is the one, thanks guys!</p>
]]></description><link>https://community.sketchucation.com/post/1443895</link><guid isPermaLink="true">https://community.sketchucation.com/post/1443895</guid><dc:creator><![CDATA[jiminy-billy-bob]]></dc:creator><pubDate>Tue, 27 May 2014 17:59:16 GMT</pubDate></item><item><title><![CDATA[Reply to Webdialog to ruby encoding issue on OSX on Sun, 25 May 2014 22:19:37 GMT]]></title><description><![CDATA[<p dir="auto">I think it is the thread dan points to...</p>
<p dir="auto">converting to unicode literal based on the string before retrieving/sending was the only thing that worked for me...</p>
<p dir="auto">the js from the test rb</p>
<pre><code>
      /* Creates a uppercase hex number with at least length digits from a given number */
      function fixedHex(number, length){
          var str = number.toString(16).toUpperCase();
          while(str.length &lt; length)
              str = "0" + str;
          return str;
      }

      /* Creates a unicode literal based on the string. nts; UTF-8 is an encoding - Unicode is a character set*/
      function unicodeLiteral(str){
          var i;
          var result = "";
          for( i = 0; i &lt; str.length; ++i){
              /* You should probably replace this by an isASCII test */
              if(str.charCodeAt(i) &gt; 126 || str.charCodeAt(i) &lt; 32)
                  result += "\\\\" + "u" + fixedHex(str.charCodeAt(i),4);
              else
                  result += str[i];
          }
    return result;
}
</code></pre>
<p dir="auto">john</p>
]]></description><link>https://community.sketchucation.com/post/1443637</link><guid isPermaLink="true">https://community.sketchucation.com/post/1443637</guid><dc:creator><![CDATA[driven]]></dc:creator><pubDate>Sun, 25 May 2014 22:19:37 GMT</pubDate></item><item><title><![CDATA[Reply to Webdialog to ruby encoding issue on OSX on Sun, 25 May 2014 21:39:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jiminy-billy-bob" aria-label="Profile: jiminy-billy-bob">@<bdi>jiminy-billy-bob</bdi></a> said:</p>
<blockquote>
<p dir="auto">I think I've read something about this a while ago, but can't find it anymore. If anyone has a link...?</p>
</blockquote>
<p dir="auto">Probably this:</p>
<p dir="auto"><a href="http://sketchucation.com/forums/viewtopic.php?f" target="_blank" rel="noopener noreferrer nofollow ugc">WebDialog encoding bug found!</a></p>
]]></description><link>https://community.sketchucation.com/post/1443633</link><guid isPermaLink="true">https://community.sketchucation.com/post/1443633</guid><dc:creator><![CDATA[Dan Rathbun]]></dc:creator><pubDate>Sun, 25 May 2014 21:39:54 GMT</pubDate></item><item><title><![CDATA[Reply to Webdialog to ruby encoding issue on OSX on Sun, 25 May 2014 21:37:04 GMT]]></title><description><![CDATA[<p dir="auto">If you query for the encoding upon the returned string (before forcing,) what do you get ?</p>
]]></description><link>https://community.sketchucation.com/post/1443632</link><guid isPermaLink="true">https://community.sketchucation.com/post/1443632</guid><dc:creator><![CDATA[Dan Rathbun]]></dc:creator><pubDate>Sun, 25 May 2014 21:37:04 GMT</pubDate></item></channel></rss>