moonsharp-devs / moonsharp

An interpreter for the Lua language, written entirely in C# for the .NET, Mono, Xamarin and Unity3D platforms, including handy remote debugger facilities.
http://www.moonsharp.org
Other
1.41k stars 213 forks source link

Fix of incorrect work of the split string with the Cyrillic symbols #283

Open MIVerTFT opened 4 years ago

MIVerTFT commented 4 years ago

Splitting a string containing the Cyrillic symbols using the gmatch method has wrong result, for example:

                s = 'Ррррр Нннннн Сссссс'
                words = {}
                for word in s:gmatch('%w+') do table.insert(words, word) end
                return words

Returns a table containing one row, although the correct result is three rows.

Added a solution to this problem and a couple of tests. I didn't quite understand why in KopiLua when working with strings char is often cast to byte, causes there is a loss of information, which leads to such bugs.