Results 1 to 1 of 1

Thread: SON.decode unicode to utf8!

  1. #1

    SON.decode unicode to utf8!

    Sorry, my english is very bad, so only examples

    Code:
    function onLoad()
    text = '{"id":"218","word":"\\u0440\\u0435\\u0433\\u0438\ \u043e\\u043d","type":"1"}'
    tbl = JSON.decode(text)
    print(tbl.id)
    print(tbl.word)
    print(tbl.type)
    end
    valid decode {"id":"218","word":"\\u0440\\u0435\\u0433\\u043 8\\ u043e\\u043d","type":"1"}
    PHP Code:
    array (
    'id' => '218',
    'word' => 'регион',
    'type' => '1',
    )
    tts script decode {"id":"218","word":"\\u0440\\u0435\\u0433\\u043 8\\ u043e\\u043d","type":"1"}
    PHP Code:
    array (
    'id' => '218',
    'word' => 'регион',
    'type' => '1',
    )
    solved a problem the next barbarian method
    Code:
    function onLoad()
    text = '{"id":"218","word":"\\u0440\\u0435\\u0433\\u0438\ \u043e\\u043d","type":"1"}'

    unitbl = {
    ['\\u0410'] = 'А', ['\\u0411'] = 'Б', ['\\u0412'] = 'В',
    ['\\u0413'] = 'Г', ['\\u0414'] = 'Д', ['\\u0415'] = 'Е',
    ['\\u0401'] = 'Ё', ['\\u0416'] = 'Ж', ['\\u0417'] = 'З',
    ['\\u0418'] = 'И', ['\\u0419'] = 'Й', ['\\u041a'] = 'К',
    ['\\u041b'] = 'Л', ['\\u041c'] = 'М', ['\\u041d'] = 'Н',
    ['\\u041e'] = 'О', ['\\u041f'] = 'П', ['\\u0420'] = 'Р',
    ['\\u0421'] = 'С', ['\\u0422'] = 'Т', ['\\u0423'] = 'У',
    ['\\u0424'] = 'Ф', ['\\u0425'] = 'Х', ['\\u0426'] = 'Ц',
    ['\\u0427'] = 'Ч', ['\\u0428'] = 'Ш', ['\\u0429'] = 'Щ',
    ['\\u042a'] = 'Ъ', ['\\u042b'] = 'Ы', ['\\u042c'] = 'Ь',
    ['\\u042d'] = 'Э', ['\\u042e'] = 'Ю', ['\\u042f'] = 'Я',
    ['\\u0430'] = 'а', ['\\u0431'] = 'б', ['\\u0432'] = 'в',
    ['\\u0433'] = 'г', ['\\u0434'] = 'д', ['\\u0435'] = 'е',
    ['\\u0451'] = 'ё', ['\\u0436'] = 'ж', ['\\u0437'] = 'з',
    ['\\u0438'] = 'и', ['\\u0439'] = 'й', ['\\u043a'] = 'к',
    ['\\u043b'] = 'л', ['\\u043c'] = 'м', ['\\u043d'] = 'н',
    ['\\u043e'] = 'о', ['\\u043f'] = 'п', ['\\u0440'] = 'р',
    ['\\u0441'] = 'с', ['\\u0442'] = 'т', ['\\u0443'] = 'у',
    ['\\u0444'] = 'ф', ['\\u0445'] = 'х', ['\\u0446'] = 'ц',Nox VidMate Mobdro

    ['\\u0447'] = 'ч', ['\\u0448'] = 'ш', ['\\u0449'] = 'щ',
    ['\\u044a'] = 'ъ', ['\\u044b'] = 'ы', ['\\u044c'] = 'ь',
    ['\\u044d'] = 'э', ['\\u044e'] = 'ю', ['\\u044f'] = 'я'
    }

    for key, value in pairs(unitbl) do
    text = string.gsub(text, key, value)
    end

    tbl = JSON.decode(text)
    Last edited by enidkhan; 05-10-2019 at 02:31 PM.

Similar Threads

  1. JSON.decode a large JSON string takes forever
    By Xorbis in forum Scripting Bug Reports
    Replies: 5
    Last Post: 04-20-2019, 12:33 PM
  2. JSON.decode(unicode_string) error
    By Dlivias in forum Scripting Bug Reports
    Replies: 0
    Last Post: 02-01-2019, 04:10 PM
  3. JSON.decode unicode to utf8
    By Bartosh in forum Scripting
    Replies: 0
    Last Post: 06-14-2018, 01:20 AM
  4. JSON.decode always returns nil
    By Loodlock in forum Scripting
    Replies: 1
    Last Post: 05-18-2018, 01:55 PM
  5. When I use Atom I can't write Unicode
    By olejika in forum Bug Reports
    Replies: 3
    Last Post: 11-04-2016, 02:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •