Skip to content

Commit 6fe9eda

Browse files
committed
Minor fixes (utf8)
- Code formatting
1 parent 04d61b1 commit 6fe9eda

38 files changed

+118
-127
lines changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
local input = "Ницца!"
2-
local codepoints = { utf8.byte( input, 1, utf8.len(input) ) }
2+
local codepoints = {utf8.byte(input, 1, utf8.len(input))}
33

4-
for index, codepoint in ipairs( codepoints ) do
5-
outputConsole( "Codepoint @ ".. index .." = ".. codepoint )
6-
end
4+
for index, codepoint in ipairs(codepoints) do
5+
outputConsole("Codepoint @ " .. index .. " = " .. codepoint)
6+
end
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
local first = utf8.byte( "Multi Theft Auto", 1, 1 )
2-
outputConsole( first ) -- 77
1+
local first = utf8.byte("Multi Theft Auto", 1, 1)
2+
outputConsole(first) -- 77
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
local input = "Hello World"
2-
local codepoints = { utf8.byte( input, 1, utf8.len(input) ) }
3-
local joined = utf8.char( unpack(codepoints) )
2+
local codepoints = {utf8.byte(input, 1, utf8.len(input))}
3+
local joined = utf8.char(unpack(codepoints))
44

5-
print( joined ) -- Hello World
5+
print(joined) -- Hello World
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
local mta = utf8.char( 77, 84, 65 )
2-
print( mta ) -- MTA
1+
local mta = utf8.char(77, 84, 65)
2+
print(mta) -- MTA

functions/UTF8_Library/examples/utf8.char-3.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ local codepoints = {}
33

44
-- Extract first 5 characters (read: Mutli)
55
for index = 1, 5 do
6-
codepoints[index] = utf8.byte( input, index )
6+
codepoints[index] = utf8.byte(input, index)
77
end
88

99
local output = ""
1010

1111
-- Join the first 5 characters together
1212
for index = 1, #codepoints do
13-
output = output .. utf8.char( codepoints[index] )
13+
output = output .. utf8.char(codepoints[index])
1414
end
1515

16-
outputConsole( output ) -- Multi
16+
outputConsole(output) -- Multi
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
local position, codepoint = utf8.charpos( "Привет", 2 )
2-
print( position, codepoint ) -- 3, 1088
1+
local position, codepoint = utf8.charpos("Привет", 2)
2+
print(position, codepoint) -- 3, 1088
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
local input = "Привет мир" -- Hello World
2-
local from = utf8.charpos( input, 1 ) -- 1
3-
local to = utf8.charpos( input, 2 ) -- 3
2+
local from = utf8.charpos(input, 1) -- 1
3+
local to = utf8.charpos(input, 2) -- 3
44

55
local byteLength = to - from
6-
outputConsole( byteLength ) -- 2
6+
outputConsole(byteLength) -- 2
77

8-
local character = string.sub( input, from, byteLength )
9-
outputConsole( character ) -- П
8+
local character = string.sub(input, from, byteLength)
9+
outputConsole(character) -- П
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
local output = utf8.escape( "%123 %u123 %{123} %u{123} %xABC %x{ABC}" )
2-
print( output ) -- { { { { ઼ ઼
1+
local output = utf8.escape("%123 %u123 %{123} %u{123} %xABC %x{ABC}")
2+
print(output) -- { { { { ઼ ઼
33

4-
local output = utf8.escape( "%%123 %? %d %%u" )
5-
print( output ) -- %123 ? d %u
4+
local output = utf8.escape("%%123 %? %d %%u")
5+
print(output) -- %123 ? d %u
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
print( utf8.find( "Hello MTA User", "User" ) ) -- 11, 14
2-
print( utf8.find( "Hello MTA User", "e" ) ) -- 2, 2
3-
print( utf8.find( "Hello MTA User", "e", 3 ) ) -- 13, 13
4-
print( utf8.find( "Привет Привет", "%s" ) ) -- 7, 7
5-
print( utf8.find( "Привет Привет", "%s", 1, true ) ) -- nil
1+
print(utf8.find("Hello MTA User", "User")) -- 11, 14
2+
print(utf8.find("Hello MTA User", "e")) -- 2, 2
3+
print(utf8.find("Hello MTA User", "e", 3)) -- 13, 13
4+
print(utf8.find("Привет Привет", "%s")) -- 7, 7
5+
print(utf8.find("Привет Привет", "%s", 1, true)) -- nil
66

77
-- Comparsion of utf8.find and string.find
8-
local startpos, endpos = utf8.find( "Привет", "и" )
9-
print( startpos, endpos ) -- 3, 3
8+
local startpos, endpos = utf8.find("Привет", "и")
9+
print(startpos, endpos) -- 3, 3
1010

11-
local startpos, endpos = string.find( "Привет", "и" )
12-
print( startpos, endpos ) -- 5, 6
11+
local startpos, endpos = string.find("Привет", "и")
12+
print(startpos, endpos) -- 5, 6
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
local output = utf8.lower( "WHAT ARE YOU UP TO? Do you like uppercase?" )
2-
print( output ) -- what are you up to? do you like uppercase?
1+
local output = utf8.lower("WHAT ARE YOU UP TO? Do you like uppercase?")
2+
print(output) -- what are you up to? do you like uppercase?
33

4-
local value = utf8.fold( 1088 )
5-
print( type( value ) ) -- number
4+
local value = utf8.fold(1088)
5+
print(type(value)) -- number

0 commit comments

Comments
 (0)