Leaderboard
Popular Content
Showing content with the highest reputation on 10/31/2020 in File Comments
-
Thanks for sharing this, I found it gets more complicated with some when the 2nd utf value changes and some have replacement characters from the letter like symbols category, this is not near as elegant as your original example which i expanded upon but it works utf_8_arrays = { [1] = {[1]= {144,128},[2]= {144,154},[3]= 4,[4]="Mathematical Bold"}, [2] = {[1]= {148,132},[2]= {148,158},[3]= 4,[4]="Mathematical Fraktur",[5]={{67,173},{72,140},{73,145},{82,156},{90,168}}}, [3] = {[1]= {152,136},[2]= {152,162},[3]= 4,[4]="Mathematical Sans-Serif Italic"}, [4] = {[1]= {153,176,81,154,128},[2]= {154,138},[3]= 4,[4]="Mathematical Monospace"}, [5] = {[1]= {144,180,77,145,128},[2]= {145,142},[3]= 4,[4]="Mathematical Italic",[5]={{104,142}}}, [6] = {[1]= {145,168,89,146,128},[2]= {146,130},[3]= 4,[4]="Mathematical Bold Italic"}, [7] = {[1]= {146,156},[2]= {146,182,107,147,128},[3]= 4,[4]="Mathematical Script",[5]={{66,172},{69,176} ,{70,177},{72,139},{73,144},{76,146},{77,179},{82,155},{101,175},{103,138},{111,180}}}, [8] = {[1]= {147,144},[2]= {147,170,119,148,128},[3]= 4,[4]="Mathematical Bold Script"}, [9] = {[1]= {148,184,73,149,128},[2]= {149,146},[3]= 4,[4]="Mathematical Double-Struck",[5]={{67,130},{72,141},{78,149},{80,153},{81,154},{82,157},{90,164}}}, [10] = {[1]= {149,172,85,150,128},[2]= {150,134},[3]= 4,[4]="Mathematical Bold Fraktur"}, [11] = {[1]= {150,160},[2]= {150,186,103,151,128},[3]= 4,[4]="Mathematical Sans-Serif"}, [12] = {[1]= {151,148},[2]= {151,174,115,152,128},[3]= 4,[4]="Mathematical Sans-Serif Bold"}, [13] = {[1]= {152,188,69,153,128},[2]= {153,150},[3]= 4,[4]="Mathematical Sans-Serif Bold Italic"}, [14] = {[1]= {146,182,75,147,128},[2]= {147,144},[3]= 3,[4]="Mathematical Monospace"}, [15] = {[1]= {132,176,81,133,128},[2]= {132,176,81,133,128},[3]= 4,[4]="Circled Latin"}, [16] = {[1]= {133,144},[2]= {133,144},[3]= 4,[4]="Squared Latin"}, [17] = {[1]= {133,176,81,134,128},[2]= {133,176,81,134,128},[3]= 4,[4]="Negative Squared Latin"}, [18] = {[1]= {135,166},[2]= {135,166},[3]= 4,[4]="Regional Indicator Symbol"}, } local Convert = function (a,ci) uo = 65 upper_start = utf_8_arrays[ci][1] upper_start_1 = utf_8_arrays[ci][1][1] upper_start_2 = utf_8_arrays[ci][1][2] - uo lo = 97 lower_start = utf_8_arrays[ci][2] lower_start_1 = utf_8_arrays[ci][2][1] lower_start_2 = utf_8_arrays[ci][2][2] - lo local Check = function (C) if string.byte(C) >= 65 and string.byte(C) <= 90 then if #upper_start > 2 and string.byte(C) >= upper_start[3] then if #upper_start == 5 then fix = upper_start[3] - uo upper_start_1 = upper_start[4] upper_start_2 = upper_start[5] - fix - uo end else upper_start_1 = utf_8_arrays[ci][1][1] upper_start_2 = utf_8_arrays[ci][1][2] - uo end upper_case = true return true elseif string.byte(C) >= 97 and string.byte(C) <= 122 then if #lower_start > 2 and string.byte(C) >= lower_start[3] then if #lower_start == 5 then fix = lower_start[3] - lo lower_start_1 = lower_start[4] lower_start_2 = lower_start[5] - fix - lo end else lower_start_1 = utf_8_arrays[ci][2][1] lower_start_2 = utf_8_arrays[ci][2][2] - lo end upper_case = false return true end end if utf_8_arrays[ci][1][2] == utf_8_arrays[ci][2][2] then a = string.upper(a) end local A = "" string.gsub(a,"(.)",function(a) if ci >= 15 then sp = 159 else sp = 157 end if ci == 18 then lb = string.char(0xE2,0x81,0xA0) else lb = "" end if #utf_8_arrays[ci] == 5 then for index,v in pairs(utf_8_arrays[ci][5]) do if v[1] == string.byte(a) then A = A.. string.char(226,132,v[2]) goto e end end end if Check(a) == true and upper_case == true and utf_8_arrays[ci][3] == 4 then A = A.. string.char(240,sp,upper_start_1,(upper_start_2+string.byte(a)))..lb elseif Check(a) == true and upper_case == true and utf_8_arrays[ci][3] == 3 then A = A.. string.char(226,upper_start_1,(upper_start_2+string.byte(a))) elseif Check(a) == true and upper_case == false and utf_8_arrays[ci][3] == 4 then A = A.. string.char(240,sp,lower_start_1,(lower_start_2+string.byte(a))) elseif Check(a) == true and upper_case == false and utf_8_arrays[ci][3] == 3 then A = A.. string.char(226,lower_start_1,(lower_start_2+string.byte(a))) else A = A.. a end ::e:: end) return A end for i,v in pairs(utf_8_arrays) do print(Convert(utf_8_arrays[i][4],i)) print(Convert("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",i)) print(Convert("Hello World!",i)) print("\n") end1 point