|
@@ -142,5 +142,86 @@ is structured than what we can assume.
|
|
This procedure will output 2 times the number of UTF-8 runes in a string, a
|
|
This procedure will output 2 times the number of UTF-8 runes in a string, a
|
|
simple heuristic for CJK-only wide text.
|
|
simple heuristic for CJK-only wide text.
|
|
|
|
|
|
|
|
+**Unicode Support:**
|
|
|
|
+
|
|
|
|
+This package makes use of the `grapheme_count` procedure from the
|
|
|
|
+`core:unicode/utf8` package. It is a complete, standards-compliant
|
|
|
|
+implementation for counting graphemes and calculating visual width of a Unicode
|
|
|
|
+grapheme cluster in monospace cells.
|
|
|
|
+
|
|
|
|
+Here is a full example of how well-supported Unicode is with this package:
|
|
|
|
+
|
|
|
|
+ package main
|
|
|
|
+
|
|
|
|
+ import "core:fmt"
|
|
|
|
+ import "core:io"
|
|
|
|
+ import "core:os"
|
|
|
|
+ import "core:text/table"
|
|
|
|
+
|
|
|
|
+ scripts :: proc(w: io.Writer) {
|
|
|
|
+ t: table.Table
|
|
|
|
+ table.init(&t)
|
|
|
|
+ table.caption(&t, "Tést Suite")
|
|
|
|
+ table.padding(&t, 1, 3)
|
|
|
|
+ table.header_of_aligned_values(&t, {{.Left, "Script"}, {.Center, "Sample"}})
|
|
|
|
+
|
|
|
|
+ table.row(&t, "Latin", "At vero eos et accusamus et iusto odio dignissimos ducimus,")
|
|
|
|
+ table.row(&t, "Cyrillic", "Ру́сский язы́к — язык восточнославянской группы славянской")
|
|
|
|
+ table.row(&t, "Greek", "Η ελληνική γλώσσα ανήκει στην ινδοευρωπαϊκή οικογένεια")
|
|
|
|
+ table.row(&t, "Younger Futhark", "ᚴᚢᚱᛘᛦ ᚴᚢᚾᚢᚴᛦ ᚴᛅᚱᚦᛁ ᚴᚢᛒᛚ ᚦᚢᛋᛁ ᛅᚠᛏ ᚦᚢᚱᚢᛁ ᚴᚢᚾᚢ ᛋᛁᚾᛅ ᛏᛅᚾᛘᛅᚱᚴᛅᛦ ᛒᚢᛏ")
|
|
|
|
+ table.row(&t, "Chinese hanzi", "官話為汉语的一支,主體分布在中国北部和西南部的大部分地区。")
|
|
|
|
+ table.row(&t, "Japanese kana", "いろはにほへとちりぬるをわかよたれそつねならむ")
|
|
|
|
+ table.row(&t, "Korean hangul", "한글, 조선글은 한국어의 공식문자로서, 세종이 한국어를")
|
|
|
|
+ table.row(&t, "Thai", "ภาษาไทย หรือ ภาษาไทยกลาง เป็นภาษาในกลุ่มภาษาไท ซึ่งเป็นกลุ่มย่อยของตระกูลภาษาขร้า-ไท")
|
|
|
|
+ table.row(&t, "Georgian", "ქართული ენა — ქართველურ ენათა ოჯახის ენა. ქართველების მშობლიური ენა,")
|
|
|
|
+ table.row(&t, "Armenian", "Իր շուրջ հինգհազարամյա գոյության ընթացքում հայերենը շփվել է տարբեր")
|
|
|
|
+ table.row(&t)
|
|
|
|
+ table.row_of_aligned_values(&t, {{.Left, "Arabic"}, {.Right, "ٱللُّغَةُ ٱلْعَرَبِيَّة هي أكثر اللغات السامية تحدثًا، وإحدى أكثر"}})
|
|
|
|
+ table.row_of_aligned_values(&t, {{.Left, "Hebrew"}, {.Right, "עִבְרִית היא שפה שמית, ממשפחת השפות האפרו-אסייתיות, הידועה"}})
|
|
|
|
+ table.row(&t)
|
|
|
|
+ table.row(&t, "Swedish", "Växjö [ˈvɛkːˌɧøː] är en tätort i södra Smålands inland samt centralort i Växjö kommun")
|
|
|
|
+ table.row(&t, "Saxon", "Hwæt! We Gardena in geardagum, þeodcyninga, þrym gefrunon, hu ða æþelingas ellen fremedon.")
|
|
|
|
+ table.row(&t)
|
|
|
|
+ table.aligned_row_of_values(&t, .Center, "Emoji (Single codepoints)", "\U0001f4ae \U0001F600 \U0001F201 \U0001F21A")
|
|
|
|
+ table.row(&t, "Excessive Diacritics", "H̷e̶l̵l̸o̴p̵e̷ ̸w̶o̸r̵l̶d̵!̴")
|
|
|
|
+
|
|
|
|
+ table.write_plain_table(w, &t)
|
|
|
|
+ fmt.println()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ main :: proc() {
|
|
|
|
+ stdout := os.stream_from_handle(os.stdout)
|
|
|
|
+
|
|
|
|
+ scripts(stdout)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+This will print out:
|
|
|
|
+
|
|
|
|
+ +----------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+ | Tést Suite |
|
|
|
|
+ +-----------------------------+----------------------------------------------------------------------------------------------+
|
|
|
|
+ | Script | Sample |
|
|
|
|
+ +-----------------------------+----------------------------------------------------------------------------------------------+
|
|
|
|
+ | Latin | At vero eos et accusamus et iusto odio dignissimos ducimus, |
|
|
|
|
+ | Cyrillic | Ру́сский язы́к — язык восточнославянской группы славянской |
|
|
|
|
+ | Greek | Η ελληνική γλώσσα ανήκει στην ινδοευρωπαϊκή οικογένεια |
|
|
|
|
+ | Younger Futhark | ᚴᚢᚱᛘᛦ ᚴᚢᚾᚢᚴᛦ ᚴᛅᚱᚦᛁ ᚴᚢᛒᛚ ᚦᚢᛋᛁ ᛅᚠᛏ ᚦᚢᚱᚢᛁ ᚴᚢᚾᚢ ᛋᛁᚾᛅ ᛏᛅᚾᛘᛅᚱᚴᛅᛦ ᛒᚢᛏ |
|
|
|
|
+ | Chinese hanzi | 官話為汉语的一支,主體分布在中国北部和西南部的大部分地区。 |
|
|
|
|
+ | Japanese kana | いろはにほへとちりぬるをわかよたれそつねならむ |
|
|
|
|
+ | Korean hangul | 한글, 조선글은 한국어의 공식문자로서, 세종이 한국어를 |
|
|
|
|
+ | Thai | ภาษาไทย หรือ ภาษาไทยกลาง เป็นภาษาในกลุ่มภาษาไท ซึ่งเป็นกลุ่มย่อยของตระกูลภาษาขร้า-ไท |
|
|
|
|
+ | Georgian | ქართული ენა — ქართველურ ენათა ოჯახის ენა. ქართველების მშობლიური ენა, |
|
|
|
|
+ | Armenian | Իր շուրջ հինգհազարամյա գոյության ընթացքում հայերենը շփվել է տարբեր |
|
|
|
|
+ | | |
|
|
|
|
+ | Arabic | ٱللُّغَةُ ٱلْعَرَبِيَّة هي أكثر اللغات السامية تحدثًا، وإحدى أكثر |
|
|
|
|
+ | Hebrew | עִבְרִית היא שפה שמית, ממשפחת השפות האפרו-אסייתיות, הידועה |
|
|
|
|
+ | | |
|
|
|
|
+ | Swedish | Växjö [ˈvɛkːˌɧøː] är en tätort i södra Smålands inland samt centralort i Växjö kommun |
|
|
|
|
+ | Saxon | Hwæt! We Gardena in geardagum, þeodcyninga, þrym gefrunon, hu ða æþelingas ellen fremedon. |
|
|
|
|
+ | | |
|
|
|
|
+ | Emoji (Single codepoints) | 💮 😀 🈁 🈚 |
|
|
|
|
+ | Excessive Diacritics | H̷e̶l̵l̸o̴p̵e̷ ̸w̶o̸r̵l̶d̵!̴ |
|
|
|
|
+ +-----------------------------+----------------------------------------------------------------------------------------------+
|
|
|
|
+
|
|
*/
|
|
*/
|
|
package text_table
|
|
package text_table
|