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

    [Code] file_found?(path) and to_ascii+to_unicode.rb

    Scheduled Pinned Locked Moved Developers' Forum
    42 Posts 5 Posters 5.9k 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.
    • TIGT Offline
      TIG Moderator
      last edited by

      thomthom

      She's all yours...

      If you want me to remove any early stuff let me know [PM etc]...

      TIG

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

        I think it can stick with the friendly names you suggested.
        I'm doing more research. Just signed up for a Ruby forum to work out how Ruby behaves. Once I've gathered the info I need I'll make a thread describing the findings.

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

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

          FYI, for anyone that (most unlikely) might be following on my ramblings - I've initiated a new thread over at a Ruby forum for further investigations: http://www.ruby-forum.com/topic/191016#833043

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

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

            I'm fairly confident that it's ISO 8859-1 which .pack('C*') generates. As long as the characters fits into ISO 8859-1 the UTF-8 can be converted with the pack/unpack methods. If they fall outside, other solutions are needed.

            One annoying finding with this is that the Euro symbol seem to be impossible to use. When ruby comes across this in a UTF-8 string it chokes and throws an error.

            I'll begin writing up this to something more readable than today's ramblings.

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

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

              sigh
              Euro can be used - just not typed into the Console. You might get it passed via SU's ruby method if it's used in a material name or component name. though .unpack('U') will return 8364 for it. Way outside the code point for ISO 8859-1. However, if you type in the octal value "\200" you get the Euro in a 1byte length string. So it should be mappable. But pack and unpack doesn't map the Unicode points between 128-160 well. So I'll be looking for a better conversion.

              I've heard of Iconv, but that's an Win API call I think - not a solution for Mac.

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

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

                I am glad you have taken such a complicated thing over .... 😄

                TIG

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

                  @tig said:

                  I am glad you have taken such a complicated thing over .... 😄

                  I'm not... 🤢 This makes my head hurt.
                  But I need to know.

                  But at least it beats sudoko puzzles... 😉

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

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

                    @thomthom said:

                    But at least it beats sudoko puzzles... 😉

                    I can do those !!! 😉

                    TIG

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

                      😄

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

                      1 Reply Last reply Reply Quote 0
                      • daikuD Offline
                        daiku
                        last edited by

                        @tig said:

                        @thomthom said:

                        But at least it beats sudoko puzzles... 😉

                        I can do those !!! 😉

                        But can you generate a puzzle using ruby code? Sounds like an idea for a ruby challenge.

                        Clark Bremer
                        http://www.northernlightstimberframing.com

                        1 Reply Last reply Reply Quote 0
                        • T Offline
                          tomasz
                          last edited by

                          I am looking into this issue right now. I haven't found anything more then TIG and Thomas has figured out. I have even started to code a C extension to return proper string converted from Ruby UTF-8, but my poor C knowledge doesn't let me progress fast.
                          As far as I understand Win uses UTF-16 format, but the whole encoding thing hurts my head badly.
                          Have someone made any progress on this issue?

                          Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

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

                            What are you trying to do? String conversion? Or deal with files with unicode characters?

                            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
                              tomasz
                              last edited by

                              @thomthom said:

                              What are you trying to do? String conversion? Or deal with files with unicode characters?

                              I am trying to create a file with a path/filename containing for example Polish characters 'Błąd.xml'. They are not part of ISO 8859-1 so the .pack('C*') doesn't generate proper path and file will be created under different name 'Błąd.xml'

                              Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

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

                                Right, what you want to do is make your C extension call the Unicode version of the file API's - as converting from Unicode to ASCII in order to try and make Ruby's file functions work will in most cases not work.

                                Note that the ASCII limitation for SketchUp's Ruby file functions exist only under Windows. Under OSX they should work AFAIK.

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

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

                                  Do not ignore Dan Berger's windows-pr package. It goes along with his win32-api package. Has the Windows "unicode.rb"

                                  In windows-apt-0.4.0 there's a complementary file "wide_string.rb"

                                  I'm not here much anymore.

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

                                  Advertisement