sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Help with Japanese Kanji in file name.

    Scheduled Pinned Locked Moved Developers' Forum
    10 Posts 3 Posters 956 Views 3 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.
    • honoluludesktopH Offline
      honoluludesktop
      last edited by

      I have a plugin that appears to fail when accessing a Drive\Path\FileName that has a folder written in Japanese. Ruby Console message reads:

      "Error: #<Errno::ENOENT: No such file or directory - C:\Documents and Settings\corbella\γƒ‡γ‚Ήγ‚―γƒˆγƒƒγƒ—\test_v2000.dxf> C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/dxf_In_v2.0.rb:228:ininitialize'
      .
      .
      .The plugin code at 228 is: aFile=File.open(chosen_file, "r")`

      where chosen_file is the result of:
      chosen_file=UI.openpanel("Select DXF File","", "*.Dxf")

      Any ideas? If it matters at all, I am using NotePad++ to write, and save the code.

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        No way around that. Ruby 1.8 under Windows doesn't handle unicode characters in files. You're stuck with requiring the users to only use ASCII characters.
        http://forums.sketchucation.com/viewtopic.php?f=180&t=20657

        😞

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

        1 Reply Last reply Reply Quote 0
        • honoluludesktopH Offline
          honoluludesktop
          last edited by

          OK, Thanks:(

          1 Reply Last reply Reply Quote 0
          • honoluludesktopH Offline
            honoluludesktop
            last edited by

            If I error trap the problem part of the code, and a future version of Ruby permits Japanese characters, will the code as written be OK?

            .
            .
            begin
              aFile=File.open(chosen_file, "r") 
            rescue
              #put error message here
              return # exit the program
            end
            .
            

            .

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              Yes.

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

              1 Reply Last reply Reply Quote 0
              • honoluludesktopH Offline
                honoluludesktop
                last edited by

                OK, Thanks.

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

                  Daniel Berger's win32-api libraries have some character conversion methods that may help. But your users will have to have his libs installed on their Windows machines.

                  The specific lib file is named unicode.rb, and is part of the windows-pr library (which I believe also requires the win32-api library.)

                  They are available as gems, (choose the highest version) from:
                  http://rubygems.org/search?page=1&query=win32-&utf8=%E2%9C%93

                  Or source from his Github pages:
                  windows-pr
                  https://github.com/djberg96/windows-pr

                  win32-api
                  https://github.com/djberg96/win32-api

                  I'm not here much anymore.

                  1 Reply Last reply Reply Quote 0
                  • honoluludesktopH Offline
                    honoluludesktop
                    last edited by

                    Thanks Dan, But I rather not mess with his machine.

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

                      Ruby was written in Japan by guys who use Kanji.

                      From the "Pick-Axe" book:
                      http://phrogz.net/ProgrammingRuby/rubyworld.html#rubyanditsworld

                      @unknownuser said:

                      Command-Line Options

                      -K kcode
                      Specifies the code set to be used. This option is useful mainly when Ruby is used for Japanese-language processing. kcode may be one of: e, E for EUC; s, S for SJIS; u, U for UTF-8; or a, A, n, N for ASCII.

                      Link Preview Image
                      The Ruby Language

                      favicon

                      (phrogz.net)

                      @unknownuser said:

                      Source Layout

                      Ruby programs are written in 7-bit ASCII. (Ruby also has extensive support for Kanji, using the EUC, SJIS, or UTF-8 coding system. If a code set other than 7-bit ASCII is used, the KCODE option must be set appropriately, as shown in the section on command-line options.)

                      At the command line, the setting is accessed via the global $KCODE

                      $KCODE

                      UTF8
                      (This is set by Sketchup just after it loads Ruby.)

                      $KCODE='S'

                      SJIS

                      $KCODE='E'

                      EUC

                      $KCODE='U'

                      UTF8

                      Don't know if changing it "on-the-fly" will help.. but it may be worth a shot. (Change it back to UTF8 after processing the pathstring.)

                      I'm not here much anymore.

                      1 Reply Last reply Reply Quote 0
                      • honoluludesktopH Offline
                        honoluludesktop
                        last edited by

                        Sorry Dan, Guess this is over my head, but thanks anyway.

                        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