2 * Copyright (c) 2014, Juniper Networks, Inc.
4 * This SOFTWARE is licensed under the LICENSE provided in the
5 * ../Copyright file. By downloading, installing, copying, or otherwise
6 * using the SOFTWARE, you agree to be bound by the terms of that
8 * Phil Shafer, July 2014
17 #include "xo_config.h"
20 #include "xo_wcwidth.h"
21 #else /* LIBXO_WCWIDTH */
22 #define xo_wcwidth(_x) wcwidth(_x)
23 #endif /* LIBXO_WCWIDTH */
26 { "employee", "object", "Employee data" },
27 { "first-name", "string", "First name of employee" },
28 { "last-name", "string", "Last name of employee" },
29 { "department", "number", "Department number" },
30 { "percent-time", "number", "Percentage of full & part time (%)" },
32 int info_count = (sizeof(info) / sizeof(info[0]));
35 main (int argc, char **argv)
44 { "Jim", "რეგტ", "გთხოვთ ახ", 431, 90 },
45 { "Terry", "<one", "Οὐχὶ ταὐτὰ παρίσταταί μοι Jones", 660, 90 },
46 { "Leslie", "Les", "Patterson", 341,60 },
47 { "Ashley", "Ash", "Meter & Smith", 1440, 40 },
48 { "0123456789", "0123456789", "012345678901234567890", 1440, 40 },
49 { "ახლა", "გაიარო", "საერთაშორისო", 123, 90 },
50 { "෴ණ්ණ෴෴ණ්ණ෴", "Mick",
51 "෴ණ්ණ෴෴ණ්ණ෴෴ණ්ණ෴෴෴", 110, 20 },
56 argc = xo_parse_args(argc, argv);
60 xo_set_info(NULL, info, info_count);
61 xo_set_flags(NULL, XOF_COLUMNS);
63 xo_open_container("indian-languages");
65 xo_emit("{T:Sample text}\n");
66 xo_emit("This sample text was taken from the Punjabi Wikipedia "
67 "article on Lahore and transliterated into the Latin script.\n");
69 xo_emit("{T:Gurmukhi:}\n");
70 xo_emit("{:gurmukhi}\n",
71 "ਲਹੌਰ ਪਾਕਿਸਤਾਨੀ ਪੰਜਾਬ ਦੀ ਰਾਜਧਾਨੀ ਹੈ । ਲੋਕ ਗਿਣਤੀ ਦੇ ਨਾਲ ਕਰਾਚੀ ਤੋਂ ਬਾਅਦ ਲਹੌਰ ਦੂਜਾ ਸਭ ਤੋਂ ਵੱਡਾ ਸ਼ਹਿਰ ਹੈ । ਲਹੌਰ ਪਾਕਿਸਤਾਨ ਦਾ ਸਿਆਸੀ, ਰਹਤਲੀ ਤੇ ਪੜ੍ਹਾਈ ਦਾ ਗੜ੍ਹ ਹੈ ਅਤੇ ਇਸ ਲਈ ਇਹਨੂੰ ਪਾਕਿਸਤਾਨ ਦਾ ਦਿਲ ਵੀ ਕਿਹਾ ਜਾਂਦਾ ਹੈ । ਲਹੌਰ ਦਰਿਆ-ਏ-ਰਾਵੀ ਦੇ ਕੰਢੇ ਤੇ ਵਸਦਾ ਹੈ ਤੇ ਇਸਦੀ ਲੋਕ ਗਿਣਤੀ ਇੱਕ ਕਰੋੜ ਦੇ ਨੇੜੇ ਹੈ ।");
74 xo_emit("{T:Shahmukhi:}\n");
75 xo_emit("{:shahmukhi}\n",
76 "لہور پاکستانی پنجاب دا دارالحکومت اے۔ لوک گنتی دے نال کراچی توں بعد لہور دوجا سبھ توں وڈا شہر اے۔ لہور پاکستان دا سیاسی، رہتلی تے پڑھائی دا گڑھ اے تے اس لئی ایھنوں پاکستان دا دل وی کیھا جاندا اے۔ لہور دریاۓ راوی دے کنڈھے تے وسدا اے اسدی لوک گنتی اک کروڑ دے نیڑے اے ۔");
78 xo_emit("{T:Transliteration}:\n");
79 xo_emit("{:tranliteration}\n",
80 "lahor pākistān panjāb dā dārul hakūmat ē. lōk giṇtī dē nāḷ karācī tō᷈ bāad lahor dūjā sab tō᷈ vaḍḍā shahr ē. lahor pākistān dā siāsī, rahtalī tē paṛā̀ī dā gā́ṛ ē tē is laī ihnū᷈ pākistān dā dil vī kehā jāndā ē. lahor dariāē rāvī dē kanḍē tē vasdā ē. isdī lōk giṇtī ikk karōṛ dē nēṛē ē.");
82 xo_close_container("indian-languages");
84 xo_open_container("employees");
86 wchar_t wc[] = { L'෴', L'ණ', L'්', L'ණ', 0x17D2, L'෴', 0 };
87 for (i = 0; wc[i]; i++)
88 xo_emit("Wide char: {lq:wc/%lc - %#lx - %d}\n",
89 wc[i], (unsigned long) wc[i], xo_wcwidth(wc[i]));
91 wchar_t msg[] = { L'1', 0x034f, L'2', 0x20dd, 0 };
92 for (i = 0; msg[i]; i++)
93 xo_emit("Wide char: {lq:wc/%lc - %#lx - %d}\n",
94 msg[i], (unsigned long) msg[i], xo_wcwidth((int) msg[i]));
95 xo_emit("Cool: [{:fancy/%ls}]\n", msg);
97 xo_emit("Οὐχὶ ταὐτὰ παρίσταταί μοι {:v1/%s}, {:v2/%s}\n",
98 "γιγνώσκειν", "ὦ ἄνδρες ᾿Αθηναῖοι");
100 rc = xo_emit("გთხოვთ {:v1/%s} {:v2/%s}\n",
101 "ახლავე გაიაროთ რეგისტრაცია",
102 "Unicode-ის მეათე საერთაშორისო");
103 xo_emit("{Twc:Width}{:width/%d}\n", rc);
105 /* Okay, Sinhala is uber cool ... */
106 rc = xo_emit("[{:sinhala}]\n", "෴ණ්ණ෴");
107 xo_emit("{Twc:Width}{:width/%d}\n", rc);
109 rc = xo_emit("[{:sinhala}]\n", "෴");
110 xo_emit("{Twc:Width}{:width/%d}\n", rc);
112 rc = xo_emit("[{:sinhala/%-4..4s/%s}]\n", "෴ණ්ණ෴෴ණ්ණ෴");
113 xo_emit("{Twc:Width}{:width/%d}\n", rc);
115 xo_emit("[{:not-sinhala/%-4..4s/%s}]\n", "123456");
117 rc = xo_emit("[{:tag/%s}]\n", "ර්ඝ");
118 xo_emit("{Twc:Width}{:width/%d}\n", rc);
120 xo_open_list("employee");
122 xo_emit("{T:First Name/%-25s}{T:Last Name/%-14s}"
123 "{T:/%-12s}{T:Time (%)}\n", "Department");
124 for ( ; ep->e_first; ep++) {
125 xo_open_instance("employee");
126 xo_emit("{[:-25}{:first-name/%s} ({:nic-name/\"%s\"}){]:}"
127 "{:last-name/%-14..14s/%s}"
128 "{:department/%8u}{:percent-time/%8u}\n",
129 ep->e_first, ep->e_nic, ep->e_last, ep->e_dept, ep->e_percent);
130 if (ep->e_percent > 50) {
131 xo_attr("full-time", "%s", "honest & for true");
132 xo_emit("{e:benefits/%s}", "full");
134 xo_close_instance("employee");
137 xo_close_list("employee");
138 xo_close_container("employees");