sketchucation logo sketchucation
    • Login
    1. Home
    2. qiucx
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    Q
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 8
    • Posts 21
    • Groups 1

    qiucx

    @qiucx

    10
    Reputation
    1
    Profile views
    21
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    qiucx Unfollow Follow
    registered-users

    Latest posts made by qiucx

    • [plugin] xml parser

      I need to save the complex entity of SU to xml and then load them. REXML is too slow, and the libxml-ruby is really hard to compile. Does anyone have the working lib? Or other suggestion?

      thanks.

      posted in Developers' Forum
      Q
      qiucx
    • RE: Encode in 2014 again.

      Thanks for all. The problem is done.

      The solution is to use ultraedit convert function(convert ascii to utf-8(unicode edition)). Originally, i use the notepad++ to convert utf-8 without BOM, and it seems not work as expected.

      Now, the split function can work correctly without any force_encoding, but the input from html should be converted using force_encoding("UTF-8").

      Thanks again for TIG.

      posted in Developers' Forum
      Q
      qiucx
    • RE: Encode in 2014 again.

      I have set all files to UTF-8 without BOM.

      but the error remain:

      Error: #<ArgumentError: invalid byte sequence in UTF-8>
      C:/Users/tc/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/CRSD/RequireFiles/UserManager/UserManager.rb:24:in `split'

      Can anyone have it? thanks.

      posted in Developers' Forum
      Q
      qiucx
    • RE: Encode in 2014 again.

      BUT related files like the CSV [and HTML?] are also best when similarly encoded - but they are not.

      I have used the notepad++ to change the files encoding to UTF-8 without BOM.

      "also best when similarly encoded - but they are not" how can i to do this similarly encoded?

      posted in Developers' Forum
      Q
      qiucx
    • RE: Encode in 2014 again.

      the files attached.


      userAttributes.csv


      UserManager.rb


      Login.zip

      posted in Developers' Forum
      Q
      qiucx
    • RE: Encode in 2014 again.

      i find the solution but can not know the reason.

      fileline.force_encoding("ISO-8859-1").encode("utf-8", replace: nil)

      can anyone explain it? And does anyone have better solution?

      thanks.

      posted in Developers' Forum
      Q
      qiucx
    • RE: Encode in 2014 again.

      thanks for your reply. Encoding::default_internal= "UTF-8" and Encoding::default_external= "UTF-8" are set in my entry main.rb and it works. the simple chinese character can be put correctly. However, when the split method can not work as expected. Following is the log and what is the problem with split method? thanks

      
      def getUsersInfoFromFile(fileName, path)
              arrayAttributes = Array.new
              pathAttrFile = Sketchup.find_support_file fileName, path
              if (pathAttrFile)
                  fileAttr = File.open pathAttrFile,"r;utf-8"
                  arrayFileLines = fileAttr.readlines
      
                  arrayFileLines.each do|fileline|
                      arrayFileLine = fileline.split ","
                      arrayAttributes << arrayFileLine
                  end
                  fileAttr.close
              end
              return arrayAttributes
          end
      
      

      also, when arrayFileLines = fileAttr.readlines is changed to arrayFileLines = fileAttr.encode("UTF-8").readlines, the problem remains and split error can be fixed when fileAttr.encode("ISO-8859-1").readlinesis used. can you explain? thanks again.

      Error:
      #<ArgumentError: invalid byte sequence in UTF-8>
      C:/Users/tc/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/CRSD/RequireFiles/UserManager/UserManager.rb:130:in split' C:/Users/tc/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/CRSD/RequireFiles/UserManager/UserManager.rb:130:in readLines'
      C:/Users/tc/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/CRSD/RequireFiles/UserManager/UserManager.rb:138:in getUsersInfoFromFile' C:/Users/tc/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/CRSD/RequireFiles/UserManager/UserManager.rb:27:in checkLogin'
      C:/Users/tc/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/CRSD/RequireFiles/UserManager/UserManager.rb:97:in block in login' C:/Users/tc/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/CRSD/RequireFiles/UserManager/UserManager.rb:106:in call'
      C:/Users/tc/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/CRSD/RequireFiles/UserManager/UserManager.rb:106:in show_modal' C:/Users/tc/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/CRSD/RequireFiles/UserManager/UserManager.rb:106:in login'
      C:/Users/tc/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/CRSD/RequireFiles/Main.rb:7:in <top (required)>' C:/remove/remove_SketchUp/Tools/RubyStdLib/rubygems/core_ext/kernel_require.rb:45:in require'
      C:/remove/remove_SketchUp/Tools/RubyStdLib/rubygems/core_ext/kernel_require.rb:45:in require' C:/Users/tc/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/CRSD.rb:1:in <top (required)>'

      posted in Developers' Forum
      Q
      qiucx
    • Encode in 2014 again.

      My function reads the string from csv file with utf-8 without BOM and all rb file, html files are utf-8 too.

      Now, i using "File.open pathAttrFile, "r:utf-8"" to read the string file csv file having simple chinese encode content, my problem is that the function can not work when using "split" method directly for the read utf-8 string. "fileline.force_encoding("ISO-8859-1").split "," " should be used and it works. I do not know the reason, can anyone explain it? thanks.

      
                  fileAttr = File.open pathAttrFile, "r;utf-8"
                  arrayFileLines = fileAttr.readlines
      
                  arrayFileLines.each do |fileline|
                      attrs = fileline.force_encoding("ISO-8859-1").split ","
      .....
      
      

      And if i need to pass the iso8859-1 string to html, the string should be encoded to utf-8 using .encode("UTF-8") if defined?(Encoding).

      These convert is not very convenient, does anyone have simple method to address the issue?

      thanks

      posted in Developers' Forum
      Q
      qiucx
    • RE: Xml parser in sketchup

      Thanks for your reply.

      Unfortunately, i can not use DOM parser to do xml parsing.

      [edit]
      I have used the libxml and its performance is good enough for me. I setup the old version libxml and copy the ruby files, dll to plugin folder of sketchup, it works for me.

      posted in SketchUp Discussions
      Q
      qiucx
    • Xml parser in sketchup

      In my current project, REXML is used to parse the xml file containing information used by sketchup. However, REXML hurts the performance very much so that i have to consider another xml parse lib.

      From http://www.railstips.org/blog/archives/2008/08/11/parsing-xml-with-ruby/ we can see the http://xml4r.github.io/libxml-ruby/ is good choice, but i am not very familiar with this lib, does anyone have experience for this xml parser?
      BTW, my xml file is element base in general.

      posted in SketchUp Discussions sketchup
      Q
      qiucx