Ocean West Posted January 7, 2009 Posted January 7, 2009 Text: 80 Character string 01234567890123456789012345678901234567890123456789012345678901234567890123456789 Calculation: Code = Code (Text) results: 5000049000480001300057000560005500054000530005200051000500004900048000130005700056000550005400053000520005100050000490004800013000570005600055000540005300052000510005000049000480001300057000560005500054000530005200051000500004900048000130005700056000550005400053000520005100050000490004800013000570005600055000540005300052000510005000049000480001300057000560005500054000530005200051000500004900048 Code () only evaluates to 80 characters anything longer you get a question mark. Another set of fields A text field titled Num Results input from above copied and pasted max out at 797 characters 57000560005500054000530005200051000500004900048000570005600055000540005300052000510005000049000480005700056000550005400053000520005100050000490004800057000560005500054000530005200051000500004900048000570005600055000540005300052000510005000049000480005700056000550005400053000520005100050000490004800057000560005500054000530005200051000500004900048000570005600055000540005300052000510005000049000480005700056000550005400053000520005100050000490004800057000560005500054000530005200051000500004900048000570005600055000540005300052000510005000049000480005700056000550005400053000520005100050000490004800057000560005500054000530005200051000500004900048000570005600055000540005300052000510005000049000480005700056000550005400053000520005100050000490004800057000560005500054000530005200051000500004900048 Char: Char( Num ) 160 returned characters 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 Also both functions evaluate the results in reverse order from the input the last value added to your input field becomes the first "set" of values in the results field. With each concurrent entry the prior gets padded out to five characters the letter "z" = 122 and "zy" = 12100122 also typing in "00122" or "122" if it is the first value evaluates to "z" s
The Shadow Posted January 7, 2009 Posted January 7, 2009 Also both functions evaluate the results in reverse order from the input the last value added to your input field becomes the first "set" of values in the results field. With each concurrent entry the prior gets padded out to five characters the letter "z" = 122 and "zy" = 12100122 also typing in "00122" or "122" if it is the first value evaluates to "z" This is a feature, it is designed that way to allow you to easily step through the returned number using Div() and Mod() in the correct order.
fabriceN Posted January 9, 2009 Posted January 9, 2009 I was told this was a standard in in the Unicode world, and the reason was some characters are encoded with 2 bytes (some accented or chinese scripts...) with no specific order. I know it's of no help at all but it's all I know, sorry :
comment Posted January 9, 2009 Posted January 9, 2009 I don't think bytes have anything to do with this - we're not dealing with binary numbers here. Perhaps it would be useful to recall that the result of Code() is a number. The notion that individual numbers are padded with zeros can be quite misleading. What really happens is that the code point of the second character (counting from left, in the order of input) is multiplied by 10^5 and added to the first. The code point of the third character is multiplied by 10^10 and added to the previous result, and so on. The result is a SINGLE base-10^5 number written in decimal notation. This may APPEAR similar to padding, but in fact the code point of the last character is never "padded".
The Shadow Posted January 10, 2009 Posted January 10, 2009 (edited) Another cool thing about Code(), is that script and local variables with repetitions can now be easily indexed by short strings, allowing a "structure" to faked. I'm thinking something like: Let( [$address[Code("street")] = "123 Penslyvania Dr"; $address[Code("city")] = "Washington"; $address[Code("state")] = "DC"; $address[Code("zip")] = 78204 ]; ..... ) This might allow some situations using indexed variables to be more self-documenting. Edited January 10, 2009 by Guest
Ocean West Posted January 10, 2009 Author Posted January 10, 2009 This might allow some situations using indexed variables to be more self-documenting. Very Intriguing!
comment Posted January 10, 2009 Posted January 10, 2009 BTW, beware of a misleading statement in the Help regarding accented and other composite characters: When converting a composite character such as ä (an a plus a dieresis character), the function returns the Unicode code point for the composite character. [b]Examples[/b] ... Code(“ä”) returns 228. The "(an [b]a[/b] plus a dieresis character)" part could be misunderstood to mean that the Code function also returns a single code point for the decomposed character (one that was entered in two keystrokes, an [b]a[/b] followed by a dieresis). The correct statement is as follows: When converting a precomposed character such as [b]ä[/b] (LATIN SMALL LETTER A WITH DIAERESIS), the Code function returns a single Unicode code point for the precomposed character (228). When converting the equivalent decomposed character [b]ä[/b] (LATIN SMALL LETTER A WITH DIAERESIS followed by COMBINING DIAERESIS), the function returns a distinct code point for each of the characters in the sequence (77600097). [b]Examples[/b] ... Code(“ä”) returns 228. Code(“ä”) returns 77600097. This also means that the number of distinct code points in the result of the Code() function does not necessarily reflect the length of the text.
Recommended Posts
This topic is 5794 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now