summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/Scribunto/tests/phpunit/engines/LuaCommon/UstringLibraryNormalizationTests.lua
blob: 97d794a1cdf8aa5f4e8ebc4c8105bd34f45b6a2d (plain)
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
local function tohex( s )
	local t = { s }
	for c in mw.ustring.gcodepoint( s ) do
		t[#t + 1] = string.format( "%x", c )
	end
	return table.concat( t, '\t' )
end

return {
	run = function ( c1, c2, c3, c4, c5 )
		return
			tohex( mw.ustring.toNFC( c1 ) ),
			tohex( mw.ustring.toNFC( c2 ) ),
			tohex( mw.ustring.toNFC( c3 ) ),
			tohex( mw.ustring.toNFC( c4 ) ),
			tohex( mw.ustring.toNFC( c5 ) ),
			tohex( mw.ustring.toNFD( c1 ) ),
			tohex( mw.ustring.toNFD( c2 ) ),
			tohex( mw.ustring.toNFD( c3 ) ),
			tohex( mw.ustring.toNFD( c4 ) ),
			tohex( mw.ustring.toNFD( c5 ) ),
			tohex( mw.ustring.toNFKC( c1 ) ),
			tohex( mw.ustring.toNFKC( c2 ) ),
			tohex( mw.ustring.toNFKC( c3 ) ),
			tohex( mw.ustring.toNFKC( c4 ) ),
			tohex( mw.ustring.toNFKC( c5 ) ),
			tohex( mw.ustring.toNFKD( c1 ) ),
			tohex( mw.ustring.toNFKD( c2 ) ),
			tohex( mw.ustring.toNFKD( c3 ) ),
			tohex( mw.ustring.toNFKD( c4 ) ),
			tohex( mw.ustring.toNFKD( c5 ) )
	end
}