sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Webdialog to ruby encoding issue on OSX

    Scheduled Pinned Locked Moved Developers' Forum
    22 Posts 5 Posters 730 Views 5 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • tt_suT Offline
      tt_su
      last edited by

      Btw, what is the source for this character?

      1 Reply Last reply Reply Quote 0
      • D Offline
        driven
        last edited by

        @TT

        the third last post from the other thread has a rbz that shows the issue on a mac...
        http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=57074%26amp;start=30#p518959

        returns using 'get_element_value' have bad encoding regardless of html declarations, script encodings, etc...

        something is happening internally in SU that screws things up...

        try the rbz it's harmless...

        john

        learn from the mistakes of others, you may not live long enough to make them all yourself...

        1 Reply Last reply Reply Quote 0
        • Dan RathbunD Offline
          Dan Rathbun
          last edited by

          Did someone file a bug report ?

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • D Offline
            driven
            last edited by

            @dan rathbun said:

            Did someone file a bug report ?

            I was going to but I got distracted by work and it's still on my endless todo list...

            john

            learn from the mistakes of others, you may not live long enough to make them all yourself...

            1 Reply Last reply Reply Quote 0
            • tt_suT Offline
              tt_su
              last edited by

              @driven said:

              the third last post from the other thread has a rbz that shows the issue on a mac...
              http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=57074%26amp;start=30#p518959

              So this only happen on OSX, not on Windows?

              1 Reply Last reply Reply Quote 0
              • D Offline
                driven
                last edited by

                @tt_su said:

                So this only happen on OSX, not on Windows?

                as far as I'm aware it's a mac thing...

                I think it's because the internal bash env locale defaults to "C" if not implicedly set

                > %x(locale)
                LANG=
                LC_COLLATE="C"
                LC_CTYPE="C"
                LC_MESSAGES="C"
                LC_MONETARY="C"
                LC_NUMERIC="C"
                LC_TIME="C"
                LC_ALL=
                

                whereas same call in 'Terminal.app'

                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"
                

                because it is set...
                john

                learn from the mistakes of others, you may not live long enough to make them all yourself...

                1 Reply Last reply Reply Quote 0
                • jiminy-billy-bobJ Offline
                  jiminy-billy-bob
                  last edited by

                  @driven said:

                  post a snippet, and I'll run some checks...

                  Going back to your test here

                  If you add

                  Sketchup.active_model.layers.add param_fix
                  

                  in @dlg2.add_action_callback("trans_L8_fix")

                  The layer name is displayed "élan 勢い Schwung импульс" in Layers Panel, as it is a webdialog.
                  But in Sketchup's layer window, it's displayed "\u00E9lan \u52E2\u3044 Schwung \u0438\u043C\u043F\u0443\u043B\u044C\u0441", just like what's printed in the ruby console.

                  Any thought on that?

                  TT > Yes, everything is set to UTF-8. Encoding, meta-tags

                  25% off Skatter for SketchUcation Premium Members

                  1 Reply Last reply Reply Quote 0
                  • S Offline
                    slbaumgartner
                    last edited by

                    @driven said:

                    @tt_su said:

                    So this only happen on OSX, not on Windows?

                    as far as I'm aware it's a mac thing...

                    I think it's because the internal bash env locale defaults to "C" if not implicedly set

                    > %x(locale)
                    > LANG=
                    > LC_COLLATE="C"
                    > LC_CTYPE="C"
                    > LC_MESSAGES="C"
                    > LC_MONETARY="C"
                    > LC_NUMERIC="C"
                    > LC_TIME="C"
                    > LC_ALL=
                    

                    whereas same call in 'Terminal.app'

                    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"
                    

                    because it is set...
                    john

                    I think this is because SU does not set ENV["LANG"] when launching the subshell.

                    Steve

                    1 Reply Last reply Reply Quote 0
                    • D Offline
                      driven
                      last edited by

                      @ Steve
                      do you think the two are unrelated?

                      @jiminy-billy-bob said:

                      Any thought on that?

                      if I eval it double quoted, I get élan 勢い Schwung импульс

                          puts (eval('"' + param_fix + '"'))
                      

                      works in UI.messagebox that way as well.

                      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...

                      john

                      learn from the mistakes of others, you may not live long enough to make them all yourself...

                      1 Reply Last reply Reply Quote 0
                      • jiminy-billy-bobJ Offline
                        jiminy-billy-bob
                        last edited by

                        eval works great, thanks!

                        25% off Skatter for SketchUcation Premium Members

                        1 Reply Last reply Reply Quote 0
                        • S Offline
                          slbaumgartner
                          last edited by

                          @driven said:

                          @ Steve
                          do you think the two are unrelated?
                          john

                          It's possible they have the same cause, but I am not sure how to prove that.

                          The man page for the locale command says:

                           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.
                          

                          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.

                          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?

                          Steve

                          1 Reply Last reply Reply Quote 0
                          • D Offline
                            driven
                            last edited by

                            @tt_su said:

                            So this only happen on OSX, not on Windows?

                            hi TT

                            did you get a chance to run this on your mac?

                            and did it confirm what I state, on your setup?

                            john

                            learn from the mistakes of others, you may not live long enough to make them all yourself...

                            1 Reply Last reply Reply Quote 0
                            • 1
                            • 2
                            • 1 / 2
                            • First post
                              Last post
                            Buy SketchPlus
                            Buy SUbD
                            Buy WrapR
                            Buy eBook
                            Buy Modelur
                            Buy Vertex Tools
                            Buy SketchCuisine
                            Buy FormFonts

                            Advertisement