File: text-utf.2gg

package info (click to toggle)
golf 601.4.41-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,824 kB
  • sloc: ansic: 20,020; sh: 1,171; makefile: 292
file content (52 lines) | stat: -rw-r--r-- 1,505 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
.TH GOLF 2gg $VERSION $DATE Development Tools
.SH NAME
text-utf \-  (UTF)
.SH PURPOSE
Convert text to UTF (UTF8 or UTF16) string. 

.SH SYNTAX

.RS 4
.EX

text-utf <text> \\
    [ status <status> ] \\
    [ error-text <error text> ]

.EE
.RE

.SH DESCRIPTION
text-utf will convert string value <text> to UTF. <text> itself will hold the resulting UTF string. If you don't wish <text> to be modified, make a copy of it first (see \fBcopy-string\fP). See \fButf-text\fP for the reverse conversion and data standards information.

You can obtain <status> in "status" clause. <status> number is GG_OKAY if successful, or GG_ERR_UTF if there was an error, in which case <error text> string in "error-text" clause will contain the error message.

.SH EXAMPLES

.RS 4
.EX

// Unicode value to encode to UTF8 or UTF16 (such as \\euD834\\euDD1E as a surrogate pair)
set-string txt = "\eu0459\\\[char92]"Doc\\\[char92]"\\en\\et\\eb\\ef\\er\\et\\eu21d7\\eu21d8\\et\\eu25b7\\eu25ee\\euD834\\euDD1E\\eu13eb\\eu2ca0\\eu0448\\en\\e/\\\[char92]"()\\et"

// Convert to UTF 
text-utf txt status txt_status error-text txt_error

// Expected UTF result
set-string utf = "љ\[char92]"Doc\[char92]"\en\et\eb\ef\er\et⇗⇘\et▷◮𝄞ᏫⲠш\en/\[char92]"()\et"

// Make sure conversion was successful
if-true utf not-equal txt or txt_status not-equal GG_OKAY or txt_error not-equal ""
    @Error in converting string to UTF
end-if

.EE
.RE

.SH SEE ALSO
 UTF

\fBtext-utf\fP  
\fButf-text\fP   
See all 
\fBdocumentation\fP