Skip to content

Commit 4d72504

Browse files
committed
UTF8 functions review
1 parent c2ed95d commit 4d72504

27 files changed

+292
-256
lines changed

functions/UTF8_Library/examples/utf8.byte-1.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ local input = "Ницца!"
22
local codepoints = { utf8.byte( input, 1, utf8.len(input) ) }
33

44
for index, codepoint in ipairs( codepoints ) do
5-
print( "Codepoint @ ".. index .." = ".. codepoint )
5+
outputConsole( "Codepoint @ ".. index .." = ".. codepoint )
66
end
Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
addCommandHandler("insert",
2-
function (player, command, word)
3-
if word then
4-
local output = utf8.insert( "hello ", word )
5-
outputChatBox( output, player )
6-
7-
local output = utf8.insert( "hello ", utf8.len( "hello " ) + 1, word )
8-
outputChatBox( output, player )
9-
end
10-
end
11-
)
1+
local word = 'world'
2+
local output = utf8.insert('hello ', word)
3+
print(output) -- hello world
4+
5+
local output2 = utf8.insert('hello ', utf8.len('hello ') + 1, word)
6+
print(output2) -- hello world

functions/UTF8_Library/examples/utf8.lower-1.lua

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
for position, codepoint in utf8.next, "utf8-string" do
1+
for position, codepoint in utf8.next("utf8-string") do
22
print( "Codepoint @ ".. position .." = ".. codepoint )
33
end
44

5-
for position, codepoint in utf8.next, "Как" do
5+
for position, codepoint in utf8.next("Как") do
66
print( "Codepoint @ ".. position .." = ".. codepoint )
77
end
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
local input = "Happy Now"
22

33
local output = utf8.sub( input, 1, 5 )
4-
outputChatBox( output, root, 255,255,255,true ) -- Happy
4+
outputChatBox( output ) -- Happy
55

66
local output = utf8.sub( input, -3 )
7-
outputChatBox( output, root, 255,255,255,true ) -- Now
7+
outputChatBox( output ) -- Now
88

99
local output = utf8.sub( input, -3, -1 )
10-
outputChatBox( output, root, 255,255,255,true ) -- Now
10+
outputChatBox( output ) -- Now

functions/UTF8_Library/examples/utf8.upper-1.lua

Lines changed: 0 additions & 5 deletions
This file was deleted.

functions/UTF8_Library/utf8.byte.yaml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
# Scraped from: https://wiki.multitheftauto.com/wiki/Utf8.byte
21
shared:
32
name: utf8.byte
43
description: Returns the codepoints for the i\-th through j\-th character of the
54
string passed.
65
parameters:
76
- name: input
87
type: string
9-
description: A string character sequence
8+
description: A string character sequence.
109
- name: i
1110
type: int
1211
description: An integer representing the beginning position.
@@ -17,19 +16,27 @@ shared:
1716
default: '1'
1817
examples:
1918
- path: examples/utf8.byte-1.lua
20-
description: This example will print every codepoint in the input string to the
21-
server console.
22-
side: server
19+
description: |
20+
This example will print every codepoint in the input string to the
21+
console.
22+
23+
Output:
24+
<code>
25+
Codepoint @ 1 = 1053
26+
Codepoint @ 2 = 1080
27+
Codepoint @ 3 = 1094
28+
Codepoint @ 4 = 1094
29+
Codepoint @ 5 = 1072
30+
Codepoint @ 6 = 33
31+
</code>
2332
- path: examples/utf8.byte-2.lua
2433
description: 'This example will print the codepoint of the first character (read:
2534
''M'') in the string literal.'
26-
side: client
2735
returns:
2836
values:
2937
- type: int
3038
name: value1
31-
- type: '... utf8.byte'
32-
name: value2
39+
- type: '...'
40+
name: values
3341
description: Returns a sequence of integer values from the original string if
3442
successful, nil otherwise.
35-
requires_review: true
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
1-
# Scraped from: https://wiki.multitheftauto.com/wiki/Utf8.char
21
shared:
32
name: utf8.char
43
description: Generates a string representing the character codepoints as arguments.
54
parameters:
65
- name: codepoints...
76
type: int
8-
description: MISSING_PARAM_DESC
7+
description: An variable argument sequence of code points representing the desired unicode characters.
98
examples:
109
- path: examples/utf8.char-1.lua
1110
description: This example separates an input string into single codepoints and
1211
then joins these back together, representing the original input string.
13-
side: server
1412
- path: examples/utf8.char-2.lua
1513
description: This example takes three code points to generate the string "MTA".
16-
side: server
1714
- path: examples/utf8.char-3.lua
1815
description: This example takes the first five code points from the input string
1916
and then joins them back together.
20-
side: client
2117
returns:
2218
values:
23-
- type: string utf8.char
19+
- type: string
2420
name: value
2521
description: Returns a string representation of the codepoints passed.
26-
requires_review: true
Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
# Scraped from: https://wiki.multitheftauto.com/wiki/Utf8.charpos
21
shared:
32
name: utf8.charpos
43
description: Converts the UTF\-8 codepoint position to byte\-string position.
54
parameters:
65
- name: input
76
type: string
8-
description: A string character sequence
9-
- name: int charpos
10-
type: '[,'
11-
description: MISSING_PARAM_DESC
12-
default: 0 ]
7+
description: A string character sequence.
8+
- name: charpos
9+
type: int
10+
description: An integer representing the beginning position (offset will be added/subtracted).
11+
default: '0'
1312
- name: offset
1413
type: int
1514
description: An integer representing the offset to charpos.
@@ -18,22 +17,19 @@ shared:
1817
- path: examples/utf8.charpos-1.lua
1918
description: This example takes the second codepoint character and shows the byte-string
2019
position and the codepoint character code.
21-
side: server
2220
- path: examples/utf8.charpos-2.lua
2321
description: This example extracts the first character by calculating the character
2422
length with the UTF8 functions and the inbuilt Lua function string.sub, which
2523
processes byte strings.
26-
side: client
2724
returns:
2825
values:
2926
- type: int
3027
name: value1
31-
- type: int utf8.charpos
28+
- type: int
3229
name: value2
3330
description: Returns the integer position as in a byte string and the integer
3431
codepoint at this position, nil otherwise.
3532
notes:
3633
- type: info
3734
content: Code point characters beyond the byte value range (0-127) require at
38-
least 2 bytes to represent the character
39-
requires_review: true
35+
least 2 bytes to represent the character.
Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,19 @@
1-
# Scraped from: https://wiki.multitheftauto.com/wiki/Utf8.escape
21
shared:
32
name: utf8.escape
43
description: Escapes a string to a UTF\-8 format string. It supports several escape
54
formats, see the formatting table.
65
parameters:
76
- name: input
87
type: string
9-
description: A string character sequence
8+
templateList: 'utf8Formatting'
9+
description: A string character sequence.
1010
examples:
1111
- path: examples/utf8.escape-1.lua
1212
description: This example escapes two byte-string literals to UTF-8 format by
1313
using the utf8.escape function.
14-
side: server
1514
returns:
1615
values:
17-
- type: string utf8.escape
16+
- type: string
1817
name: value
1918
description: Returns a string containing the escaped UTF-8 characters from the
20-
original string.
21-
meta:
22-
- needs_checking: 'This function was partially migrated from the old wiki. Please
23-
review manually:
24-
25-
- Missing section: Formatting
26-
27-
'
28-
requires_review: true
19+
original string.

0 commit comments

Comments
 (0)