![]() ![]() | ![]() |
Test suite for xchar added
1: \ xchar word test suite - UTF-8 only 2: 3: key? drop \ initialize terminal - will init locale in Gforth 4: hex 5: 6: { 0 xc-size -> 1 } 7: { 7f xc-size -> 1 } 8: { 80 xc-size -> 2 } 9: { 7ff xc-size -> 2 } 10: { 800 xc-size -> 3 } 11: { ffff xc-size -> 3 } 12: { 10000 xc-size -> 4 } 13: { 1fffff xc-size -> 4 } 14: 15: : test-string s" 恭喜发财!" ; 16: 17: { test-string drop xc@+ swap xc@+ swap xc@+ swap xc@+ swap xc@+ nip -> 606D 559C 53D1 8D22 21 } 18: { ffff pad 4 xc!+? -> pad 3 + 1 true } 19: { test-string drop xchar+ -> test-string drop 3 + } 20: { test-string drop xchar+ xchar- -> test-string drop } 21: { test-string +x/string -> test-string 3 /string } 22: { test-string x\string- x\string- -> test-string 4 - } 23: { test-string x-size -> 3 } 24: { test-string -trailing-garbage -> test-string } 25: { test-string 2 - -trailing-garbage -> test-string 4 - } 26: 27: { 0. <# s" Test" holds #> s" Test" compare -> 0 } 28: { 0. <# 606D xhold #> s" 恭" compare -> 0 } 29: 30: { 606D xc-width -> 2 } 31: { 41 xc-width -> 1 } 32: { 2060 xc-width -> 0 } 33: { test-string x-width -> 9 }