• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Unicode, UTF8 and Ruby

Scheduled Pinned Locked Moved Developers' Forum
19 Posts 6 Posters 2.5k Views 6 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.
  • D Offline
    Didier Bur
    last edited by 3 Mar 2008, 21:21

    @unknownuser said:

    Don't know if it has any ideas that help

    TIG, it seems the "register" method is missing. Apparently not a standard method...

    DB

    1 Reply Last reply Reply Quote 0
    • T Offline
      TIG Moderator
      last edited by 3 Mar 2008, 22:09

      But couldn't we (you!) use the pack / unpack tricks to convert between the two encoding ?

      TIG

      1 Reply Last reply Reply Quote 0
      • T Offline
        thomthom
        last edited by 28 Jun 2009, 22:22

        @unknownuser said:

        UTF8 doesn't work with the SU Ruby API. I figured out this sad bit of news when I wrote the 3DTextTool.

        UTF8 works in Ruby just fine.

        Google knows. They've known for the past several maintenance updates.

        Todd

        That was my first problem when I first tried to write ruby plugins; writing in UTF-8. From doing websites I've grown into the custom of using UTF-8 to account for most languages. I figured that I was doing something wrong and meant to go back and have another look at some point. So, essentially UTF-8 is no-go? And this is due to the SU API - not Ruby?

        Thomas Thomassen — SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • D Offline
          Didier Bur
          last edited by 29 Jun 2009, 10:29

          Good advice, thanks TIG 👍

          DB

          1 Reply Last reply Reply Quote 0
          • T Offline
            TIG Moderator
            last edited by 29 Jun 2009, 11:09

            Yes. You can't use FileTest.exist?(Sketchup.active_model.path) if the file has unicode. The 'path' SUp reports looks OK with say ascii_chr=233 for 'é', however the FileTest sees the 'é' as a unicode and so returns false - although they both 'look' the same, the character encoding is different.
            My clunky fix only works on the top-most file (or folder) containing the unicode parts, as the Dir.entities(dir) falls over if there are accents earlier in the path...
            It can't be beyond the wit of man to take 'Sketchup.active_model.path' and encode it as unicode in a way that would match the Ruby built-ins like FileTest.exist?(path) or Dir.entities(dir)... however it is beyond the wit of me... 😕

            TIG

            1 Reply Last reply Reply Quote 0
            • T Offline
              thomthom
              last edited by 29 Jun 2009, 11:25

              I think that I couldn't even get UTF-8 scripts to run... I'll have a look at Ruby + SU + UTF. Wonder if Ruby has some nice encoding methods.
              Seeing how there's many scripts that uses localisation it's be very nice to have UTF-8.
              .SKP has a weird combination of UTF+8 and regular ACSII. Seems that it wasn't originally UTF-8 and it was later added. Maybe we're running into problems due to this.

              Thomas Thomassen — SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

              1 Reply Last reply Reply Quote 0
              • T Offline
                TIG Moderator
                last edited by 29 Jun 2009, 11:54

                233.chr ### a plain ascii é
                é
                233.chr+233.chr ### 2 number plain ascii é make éé
                éé
                195.chr ### a plain ascii capital A with an umlaut
                Ã
                169.chr ### a plain ascii the (c)opyright symbol
                ©
                195.chr+169.chr ### BUT these 2 number ascii codes added together = one unicode é that looks like an ascii é !!!
                é

                ??? go figure ???

                TIG

                1 Reply Last reply Reply Quote 0
                • T Offline
                  thomthom
                  last edited by 29 Jun 2009, 12:19

                  UTF only uses two bytes for some of the characters. For most of the latin characters it uses 1byte equal to normal ASCII.

                  Thomas Thomassen — SketchUp Monkey & Coding addict
                  List of my plugins and link to the CookieWare fund

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    TIG Moderator
                    last edited by 1 Jul 2009, 13:58

                    Didieret al...

                    After more than a year and a bit...

                    typical usage: file_found?(Sketchup.active_model.path)

                    returns trueif the file found,

                    even with accented unicode characters in name/path,

                    e.g. qualisé.skp

                    EDIT: see here for latest file... http://forums.sketchucation.com/viewtopic.php?p=169225#p169225

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • T Offline
                      TIG Moderator
                      last edited by 1 Jul 2009, 14:01

                      file_found?(path) that fixes ascii in SUp Ruby path and unicode in returned filepath returning false negatives with 'FileTest.exist?(path)' - even with accented characters - is updated and moved here... http://forums.sketchucation.com/viewtopic.php?p=169225#p169225

                      TIG

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

                      Advertisement