Need Help with Non Latin/Roman Character

Aquí puedes preguntar o compartir tus dudas y conocimientos acerca del programa
Hello is anybody here can help me how to get the first letter of the non Latin/Roman character, the example i have is the Ukrainian and Chinese words.

The string from database is something like this:

"сфк ещнщкф исвнг"

and should make it like this:

result is: с. е. и.

in English words like, HONDA TOYOTA KIA will results correctly as H. T. K., but with the ukrainian words is displaying incorrect or invalid character like ��

Thank you for the help.
http://lua-users.org/wiki/LuaUnicode
https://www.lua.org/manual/5.3/manual.html#6.5

Problems:
- Lua 5.1 doesn't support UTF-8
- AMS doesn't support UTF-8

Solutions:
- There no solution directly
- You shouldn't use AMS for this project
Hi dowsher actually AMS accept non latin character if the string is from database i will display correctly in any label or paragraph. but if use String.Left or any string action it results invalid character.
I used a library once but I didn't use it in AMS, you could try.

https://github.com/meepen/Lua-5.1-UTF-8 ... r/utf8.lua


OK solved
as is usually done in amsspecialist forum :demo:






example: Izzedin Al Qassam Group
credit: Imagine Programming






HIDE: ON
Hidebb Message Hidden Description




Hi usamakey this solutions is already shared by IP in IR forum but not really work as is it.. thanks anyway..
Character set on windows are quite fucked up badly. No windows API understand unicode, and when refering to API we also talking about internal methods that set the text on controls behind lua api for example. This is very long time issue on any MS OS ever existed and it seems no plans to add unicode apis on windows for retarded it sounds.

What MS understand is only 2 character sets
  • ANSI strings, aka ASCII, aka ACP: this is where AMS lives due its implementation, characters are always a single byte (so 512 character set only possible)
  • Wide strings, aka UCS2, aka utf16le (wrongly called "unicode" in MS docs): this is way better character set altought it isnt full unicode, characters are formed by 2 bytes (it allow a character set of 65536 items)


How to use unicode on windows is at least tricky, sice everithing has to be converted to wide strings using api like MultiByteToWideChar and WideCharToMultiByte, this api converts from/to utf8, ansi or wide. Also windows apis are duplicated for example MessageBox method dont exists but its ansi/wide versions MessageBoxA and MessageBoxW. Most of the api that uses strings has this 2 variations. This is especially painful while triying to read/write files on disk, as the filenames or paths may only be usabe with wide string api, rendering ansi useless.

So how all of this does under the hood in AMS, lets pick a random method like Input.SetText, internally, it will make use of SetWindowTextA method of microsoft common controls, so theres no way to use this api with wide strings. But one could craft a UCS2 string and call to SetWindowTextW(inputhwnd, widetext) of user32.dll to write it and it would work and display the text.

AFAIK russians on ru-board suffered especially this and had "russified" version of AMS by themselves, being the same ansi implementation but setting character set to russian internally, so it dont work with many latin chars for example, as the set is quite limited.
En palabras resumidas, en windows no puedes trabajar con caracteres unicode a menos que hagas conversiones costosas y como AMS trabaja con la API nativa de Windows tiene la misma limitación...
Pabloko escribió: AFAIK russians on ru-board suffered especially this and had "russified" version of AMS by themselves, being the same ansi implementation but setting character set to russian internally, so it dont work with many latin chars for example, as the set is quite limited.

Hi dude..
I remember many discussions on the subject and a couple of toys of Tavria and Zloy_Gelud (aka Kindly) ...... that like and the ulrich plugin don't work

local ansi_decode={
  [128]='\208\130',[129]='\208\131',[130]='\226\128\154',[131]='\209\147',[132]='\226\128\158',[133]='\226\128\166',
  [134]='\226\128\160',[135]='\226\128\161',[136]='\226\130\172',[137]='\226\128\176',[138]='\208\137',[139]='\226\128\185',
  [140]='\208\138',[141]='\208\140',[142]='\208\139',[143]='\208\143',[144]='\209\146',[145]='\226\128\152',
  [146]='\226\128\153',[147]='\226\128\156',[148]='\226\128\157',[149]='\226\128\162',[150]='\226\128\147',[151]='\226\128\148',
  [152]='\194\152',[153]='\226\132\162',[154]='\209\153',[155]='\226\128\186',[156]='\209\154',[157]='\209\156',
  [158]='\209\155',[159]='\209\159',[160]='\194\160',[161]='\209\142',[162]='\209\158',[163]='\208\136',
  [164]='\194\164',[165]='\210\144',[166]='\194\166',[167]='\194\167',[168]='\208\129',[169]='\194\169',
  [170]='\208\132',[171]='\194\171',[172]='\194\172',[173]='\194\173',[174]='\194\174',[175]='\208\135',
  [176]='\194\176',[177]='\194\177',[178]='\208\134',[179]='\209\150',[180]='\210\145',[181]='\194\181',
  [182]='\194\182',[183]='\194\183',[184]='\209\145',[185]='\226\132\150',[186]='\209\148',[187]='\194\187',
  [188]='\209\152',[189]='\208\133',[190]='\209\149',[191]='\209\151'
}
local utf8_decode={
  [128]={[147]='\150',[148]='\151',[152]='\145',[153]='\146',[154]='\130',[156]='\147',[157]='\148',[158]='\132',[160]='\134',[161]='\135',[162]='\149',[166]='\133',[176]='\137',[185]='\139',[186]='\155'},
  [130]={[172]='\136'},
  [132]={[150]='\185',[162]='\153'},
  [194]={[152]='\152',[160]='\160',[164]='\164',[166]='\166',[167]='\167',[169]='\169',[171]='\171',[172]='\172',[173]='\173',[174]='\174',[176]='\176',[177]='\177',[181]='\181',[182]='\182',[183]='\183',[187]='\187'},
  [208]={[129]='\168',[130]='\128',[131]='\129',[132]='\170',[133]='\189',[134]='\178',[135]='\175',[136]='\163',[137]='\138',[138]='\140',[139]='\142',[140]='\141',[143]='\143',[144]='\192',[145]='\193',[146]='\194',[147]='\195',[148]='\196',
    [149]='\197',[150]='\198',[151]='\199',[152]='\200',[153]='\201',[154]='\202',[155]='\203',[156]='\204',[157]='\205',[158]='\206',[159]='\207',[160]='\208',[161]='\209',[162]='\210',[163]='\211',[164]='\212',[165]='\213',[166]='\214',
    [167]='\215',[168]='\216',[169]='\217',[170]='\218',[171]='\219',[172]='\220',[173]='\221',[174]='\222',[175]='\223',[176]='\224',[177]='\225',[178]='\226',[179]='\227',[180]='\228',[181]='\229',[182]='\230',[183]='\231',[184]='\232',
    [185]='\233',[186]='\234',[187]='\235',[188]='\236',[189]='\237',[190]='\238',[191]='\239'},
  [209]={[128]='\240',[129]='\241',[130]='\242',[131]='\243',[132]='\244',[133]='\245',[134]='\246',[135]='\247',[136]='\248',[137]='\249',[138]='\250',[139]='\251',[140]='\252',[141]='\253',[142]='\254',[143]='\255',[144]='\161',[145]='\184',
    [146]='\144',[147]='\131',[148]='\186',[149]='\190',[150]='\179',[151]='\191',[152]='\188',[153]='\154',[154]='\156',[155]='\158',[156]='\157',[158]='\162',[159]='\159'},[210]={[144]='\165',[145]='\180'}
}

local nmdc = {
  [36] = '$',
  [124] = '|'
}

function AnsiToUtf8(s)
  local r, b = ''
  for i = 1, s and s:len() or 0 do
    b = s:byte(i)
    if b < 128 then
      r = r..string.char(b)
    else
      if b > 239 then
        r = r..'\209'..string.char(b - 112)
      elseif b > 191 then
        r = r..'\208'..string.char(b - 48)
      elseif ansi_decode[b] then
        r = r..ansi_decode[b]
      else
        r = r..'_'
      end
    end
  end
  return r
end

function Utf8ToAnsi(s)
  local a, j, r, b = 0, 0, ''
  for i = 1, s and s:len() or 0 do
    b = s:byte(i)
    if b < 128 then
      if nmdc[b] then
        r = r..nmdc[b]
      else
        r = r..string.char(b)
      end
    elseif a == 2 then
      a, j = a - 1, b
    elseif a == 1 then
      a, r = a - 1, r..utf8_decode[j][b]
    elseif b == 226 then
      a = 2
    elseif b == 194 or b == 208 or b == 209 or b == 210 then
      j, a = b, 1
    else
      r = r..'_'
    end
  end
  return r
end

sendai escribió:
26 Feb 2020 04:11
Hi usamakey this solutions is already shared by IP
only in part and with attached thanks
Thanks usamakey// what is that you share?
thnk you
gracias
thank you