• Login
sketchucation logo sketchucation
  • Login
🔌 Quick Selection | Try Didier Bur's reworked classic extension that supercharges selections in SketchUp Download

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 3 Jan 2014, 16:29

    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
    • D Offline
      Dan Rathbun
      last edited by 4 Jan 2014, 03:33

      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
      • D Offline
        Dan Rathbun
        last edited by 4 Jan 2014, 03:39

        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
        • T Offline
          TIG Moderator
          last edited by 5 Jan 2014, 18:16

          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
          • T Offline
            tt_su
            last edited by 6 Jan 2014, 14:26

            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
            • A Offline
              AdamB
              last edited by 6 Jan 2014, 16:04

              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
              1 / 1
              • First post
                1/6
                Last post
              Buy SketchPlus
              Buy SUbD
              Buy WrapR
              Buy eBook
              Buy Modelur
              Buy Vertex Tools
              Buy SketchCuisine
              Buy FormFonts

              Advertisement