diff options
author | Don Bright <hugh.m.bright@gmail.com> | 2013-12-15 21:32:06 (GMT) |
---|---|---|
committer | Don Bright <hugh.m.bright@gmail.com> | 2013-12-15 21:32:06 (GMT) |
commit | 3b3ef44f6636affef8138f4c8b7dec1333f50377 (patch) | |
tree | 977698cc6d2d56775f140967792ad637db03490f /testdata/scad/misc/string-unicode.scad | |
parent | 5271b345bc755f37e98d7f497f6686d34990fa5c (diff) | |
parent | c7cea0082e427f3c53985845f05e8737873c8a25 (diff) |
Merge branch 'master' of github.com:openscad/openscad into planar
Conflicts:
src/CGAL_Nef_polyhedron.cc
tests/CMakeLists.txt
Diffstat (limited to 'testdata/scad/misc/string-unicode.scad')
-rw-r--r-- | testdata/scad/misc/string-unicode.scad | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/testdata/scad/misc/string-unicode.scad b/testdata/scad/misc/string-unicode.scad new file mode 100644 index 0000000..1386d63 --- /dev/null +++ b/testdata/scad/misc/string-unicode.scad @@ -0,0 +1,44 @@ +//Test length reporting +text_1bytes_len = "1234"; +text_2bytes_len = "ΠΠΠΠ"; +text_4bytes_len = "π‘π±ππ"; + +echo( "text_1bytes_len = ", text_1bytes_len, " len = ", len(text_1bytes_len) ); +echo( "text_2bytes_len = ", text_2bytes_len, " len = ", len(text_2bytes_len) ); +echo( "text_4bytes_len = ", text_4bytes_len, " len = ", len(text_4bytes_len) ); + +//Test how well arrays of unicode string are accessed. + +texts_array = [ +"DEADBEEF", +"ΠΠ΅Π½ΠΈΠ²ΡΠΉ ΡΡΠΆΠΈΠΉ ΠΊΠΎΡ", +"ΩΨ³ΩΩ Ψ§ΩΨ²ΩΨ¬Ψ¨ΩΩ Ψ§ΩΩΨ·", +"ζΆζ°ηε§θ²", +"Àâü ΓΓΓ Γ", +"πππππ
πππππππππππ", +"β β β β β
β β β β β β β β β β ", +"π‘π±ππ", +]; + +text_2bytes = "ΠΠ΅Π½ΠΈΠ²ΡΠΉ ΡΡΠΆΠΈΠΉ ΠΊΠΎΡ"; +text_4bytes = "π‘π±ππ"; + + +//Test all the normal accesses +for (text_array_idx = [0:(len(texts_array)-1)]) +{ + echo( "[", text_array_idx, "] = ", texts_array[text_array_idx], " of len=", len(texts_array[text_array_idx]), ":" ); + for (text_idx = [0:(len(texts_array[text_array_idx])-1)]) + { + echo( " [", text_idx, ,"]=", texts_array[text_array_idx][text_idx] ); + } +} + +//Test one past the last element of (x-byte unicode). This will be one past the length but inside the char length of the string +echo( "Past end of unicode only 2-byte ", text_2bytes[len(text_2bytes)] ); +echo( "Past end of unicode only 4-byte ", text_4bytes[len(text_4bytes)] ); + +//Test past the last element of (x-byte unicode). Outside both lengths. +echo( "Past end of both 2-byte ", text_2bytes[ len(text_2bytes) * 2 ] ); +echo( "Past end of both 4-byte ", text_4bytes[ len(text_4bytes) * 4 ] ); + |