summaryrefslogtreecommitdiff
path: root/testdata/scad/misc/string-unicode.scad
diff options
context:
space:
mode:
authorBrody Kenrick <user.fake@server.userfake>2013-12-05 06:56:54 (GMT)
committerMarius Kintel <marius@kintel.net>2013-12-08 23:35:35 (GMT)
commit3abf64249fd667f0b7f558ecfbbf35cfe9916a5d (patch)
treea5e3aa4699cf5b9d27693f8ab5411acdacc2fdb0 /testdata/scad/misc/string-unicode.scad
parent7075d8d9c4dde62798022bdfe02c5d57e997ba43 (diff)
Unicode support for strings
Add suport for using unicode strings in .scad files. Support iterating across them/accessing them via [] and searching. -------- Add GLIB (to build for test and normal build -- both with installed and built locally development files). Add support for unicode chars to length and search builtin functions and [] for strings. Added unicode testing functions. Ad GLIB to library info page.
Diffstat (limited to 'testdata/scad/misc/string-unicode.scad')
-rw-r--r--testdata/scad/misc/string-unicode.scad36
1 files changed, 36 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..d8e3e5c
--- /dev/null
+++ b/testdata/scad/misc/string-unicode.scad
@@ -0,0 +1,36 @@
+//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 ] );
+
+
contact: Jan Huwald // Impressum