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

    Special Characters in ENV[APPDATA] not recognized

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 5 Posters 314 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.
    • R Offline
      Rubycation
      last edited by

      Hi

      I am trying to write some config files for an extension to an users roaming appdata folder but it doesn't work when special characters are used in the user name.

      How would you deal with an username containing an ë or é? When for example the Windows Username is 'Tëst' the ENV[APPDATA] will come back with 'Tst'. This results in the inability to write the configuration file.

      Thank you for your reply!

      Alex

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

        On Windows Ruby in the 1.8 trunk cannot handle paths with Unicode characters. This causes many methods in the Ruby Dir, File and IO classes to fail.

        You will have to use Tig's PCFileTools library along with WIN32OLE class.

        💭

        I'm not here much anymore.

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

          Note that ENV interface may still return unicode characters as escaped numerics:

          %(#804000)['C:\Users\Półka\AppData\Roaming']
          may be returned as:
          "C:\\Users\\P\242lka\\AppData\\Roaming"

          🤓

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • TIGT Offline
            TIG Moderator
            last edited by

            Hopefully when [if] SketchUp gets a 'good' newer version of Ruby this PC limitation will disappear.

            If you want to allow for the less esoteric characters like é this way returns true properly - no incorrect false...

            s="C:/Users/P**ó**lka/xxx.txt" File.exist? s.unpack("U*").map{|c|begin;c.chr;rescue;c;end}.join

            BUT then
            C:/Users/Pó**ł**ka/xxxx.txt
            still returns false wrongly !

            TIG

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

              You might be able to extract the DOS 8.3 path from EVV['TEMP']. Ruby 1.8 can use DOS 8.3 paths is you have them.

              1 Reply Last reply Reply Quote 0
              • AdamBA Offline
                AdamB
                last edited by

                The only way around this I found was to write all my own Filepath handling in C++ for LightUp so handling Kanji, etc etc all works correctly.

                Developer of LightUp Click for website

                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