sketchucation logo sketchucation
    • Login
    ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

    Umlauts in Attribute names

    Scheduled Pinned Locked Moved SketchUp Discussions
    sketchup
    9 Posts 3 Posters 405 Views
    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.
    • Al HartA Offline
      Al Hart
      last edited by

      I have a client who wants to use Umlauts, etc. in attribute names in SpaceDesign, such as Länge.

      (This is a lot of "fun" for us to make work properly.)

      I tried using this name for a Dynamic Component and was warned that I can only use letters and numbers. I was able to use Umlauts in attribute values.

      Has anyone had any experience with problems and/or successes using Umlauts or other accents with Dynamic Components?

      Al Hart

      http://wiki.renderplus.com/images/e/ef/Render_plus_colored30x30%29.PNG
      IRender nXt from Render Plus

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

        You can't as far as I know... it's '7-bit ASCII' = letters and numbers and '_' only [I also avoid the use of initial uppercase letters]... Built-in attributes like 'Name' are actually stored as '_name' anyway!
        Your client will have to put up with simply missing them off, or adding an extra 'e', which are the ways most German speakers resolve it...
        Biskuittörtchen >> Biskuittortchen or Biskuittoertchen

        You can use it in value 'strings' though...
        Accented characters cause all sorts of problems with Ruby - especially in file-paths !
        Even if you got it working in a DC then its use in a file-name could cause a false not exist? result if it contains a umlaut... Encourage your client to be 'sensible'... 😄

        TIG

        1 Reply Last reply Reply Quote 0
        • Al HartA Offline
          Al Hart
          last edited by

          Thanks TIG

          Al Hart

          http://wiki.renderplus.com/images/e/ef/Render_plus_colored30x30%29.PNG
          IRender nXt from Render Plus

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

            You might be able to store special characters in attribute dictionaries, but it's Ruby's lack of Unicode that makes it difficult to handle such strings. It might be this that is the root to the DC limitations. ...maybe,,,

            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

              How do Russian users give their DC attributes names ?

              dc.definition.set_attribute("dynamic_attributes", "ë", "E+Umlaut")
              WILL write the value without an error [initially]... BUT if you open the DC dialog it displays as a 'Ã' instead and the value isn't there... and then the error messages start.
              So you can get/set a non ASCII key in code, BUT the DC webdialog fails to interpret anything other than straight ASCII codes 😕

              TIG

              1 Reply Last reply Reply Quote 0
              • Al HartA Offline
                Al Hart
                last edited by

                It gets confusing.

                Sometimes an umlaut-a is stored in ANSI as a single byte #e4 and sometimes it is stored as two bytes (UTF8 or multi-byte) as #c3 #a4.

                We made two routines to_ansi() and to_utf8() to switch back and forth.
                Many things work better if you call to_ansi() on them and convert them to single byte ansi.
                (This will work for European characters, but not for Kanji and other multi-byte characters)

                
                	def to_ansi(string)
                		return(string) if (!string || string == "" || !string.kind_of?(String))		
                		a1 = string.unpack("U*") # extract utf8 as integers
                		s1 = a1.pack("C*") # repack as ansi
                		return(s1)
                	end#def to_ansi
                	
                	def to_utf8(string)
                		a2 = string.unpack("C*") # extract extended ansi as integers
                		s2 = a2.pack("U*") # repack as utf8
                		return(s2)
                	end#def to_utf8
                
                

                and we wrote a get_ansi_attribute() which converts string attributes to ansi format which may work better.

                
                	def get_ansi_attribute(parent, dictionary_name, attribute_name, default = nil)
                		# gets the attribute and converts to extended ansi format
                		satt = parent.get_attribute(dictionary_name, attribute_name, default)
                		if (satt.kind_of?(String))
                			satt = to_ansi(satt)
                		end#if
                		return(satt)
                	end#def get_ansi_attribute
                
                

                Al Hart

                http://wiki.renderplus.com/images/e/ef/Render_plus_colored30x30%29.PNG
                IRender nXt from Render Plus

                1 Reply Last reply Reply Quote 0
                • Al HartA Offline
                  Al Hart
                  last edited by

                  to_ansi() helped a lot. I couldn't figure out how to do the same thing in C++, so I just called the internal ruby packing functions from C++.

                  
                  CString cl_ruby;;to_ansi(VALUE string_value)
                  {
                  		static VALUE unpack_intern = rb_intern("unpack");
                  		static VALUE pack_intern = rb_intern("pack");
                  
                  		CString string = CString(value_to_CString(string_value));
                  		if (string == "")
                  			return(string);
                  
                  		//a1 = string.unpack("U*") # extract utf8 as integers
                  		VALUE a1 = rb_funcall(string_value, unpack_intern, 1, CString_to_value("U*"));
                  
                  		//s1 = a1.pack("C*") # repack as ansi
                  		VALUE s1 = rb_funcall(a1, pack_intern, 1, CString_to_value("C*"));
                  
                  		CString sret = value_to_CString(s1);
                  		return(sret);
                  }
                  

                  Here is a report with umlauts in the component definition name, attribute titles, and attribute values, (using SpaceDesign)

                  http://api.ning.com/files/e15Tl8zw55OKnWQzZb*9-tHoVpSdG7ErIhLAS73T-mIHXCMoCz8ycEFJhGJx0ECcY6hzHpns5Vs9Wu34XuVBPUHqbFiXqpfi/umlaut_report.jpg

                  Al Hart

                  http://wiki.renderplus.com/images/e/ef/Render_plus_colored30x30%29.PNG
                  IRender nXt from Render Plus

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

                    You can have umlauts in other attributes_dictionaries' keys, BUT if it's a DC [dynamic_attributes dictionary] that has a key with an umlaut in it [made your way] will it be displayed/reported/edited properly in the dialog and/or NOT mess up the DC's 'operations' ?

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • Al HartA Offline
                      Al Hart
                      last edited by

                      No - neither the Ansi ä or the Multi-byte ä can be used in a DC attribute name.

                      I got off track a bit on this post. The to_ansi() function is useful when dealing with Umlauts and/or accents which are converted from ANSI/Extender ASCII to Multi-Byte automatically by Ruby or SketchUp. But still doesn't solve the original problem.

                      I will be interested to see if it help with Web Dialogs or other problems.

                      Al Hart

                      http://wiki.renderplus.com/images/e/ef/Render_plus_colored30x30%29.PNG
                      IRender nXt from Render Plus

                      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