-- Euphoria 3.2.00,ru bilingual (English & Russian) library, cp866, -- for the bilingual interpreters with unlimited alphabet -- ex_r.exe, exw_r.exe, exu_r and eu_r.ex. -- Analog of the pure English version (rus_add.e) by Igor Kachan, -- this version doesn't work with the standard RDS interpreters. -- 28.02.2006 - fixed bug, thanks to Wolfgang Fritz -- 06.03.2011 - utf-8 encoding added -- ------! ࣠ ⥪ ४஢!!!!--------- ------------Attention! Do not recode this library!!!!------------------- global sequence codes -------------------------------------------------- --᫨ । ⮪, ᮡ ⥫-------------- --edit with very care--------------------------------------------------- sequence d,w,k,i,m,r,u,U------------------------------------------------ d="񦧨"--866 w="Ũ"--1251 k="ţ"--koi8-r i=""--8859-5 m="݆"--apple r="ABVGDEegZIJKLMNOPRSTUFHCXsz_Y_eWQabvgdeEGzijklmnoprstufhcxSZ_y_Ewq"--rlr u=""--utf-8b U=""--utf-8a codes={d,w,k,i,m,r,u,U}------------------------------------------------- --edit with very care--------------------------------------------------- --᫨ । ⮪, ᮡ ⥫-------------- ------! ࣠ ⥪ ४஢!!!!--------- ------------Attention! Do not recode this library!!!!------------------- -- global function case_ru(integer c, object x, sequence cp) -- convert Russian atom or sequence -- to upper or to lower case integer n sequence A, a if equal(cp,"dos") then n=1 elsif equal(cp,"win") then n=2 elsif equal(cp,"koi") then n=3 elsif equal(cp,"iso") then n=4 elsif equal(cp,"mac") then n=5 else n=0 end if if not n then return n end if if c then A=codes[n][ 1..33] a=codes[n][34..66] else a=codes[n][ 1..33] A=codes[n][34..66] end if if atom(x) then n=find(x,a) if n then return A[n] end if else for i=1 to length(x) do n=find(x[i],a) if n then x[i] = A[n] end if end for end if return x end function -- case_ru() global function case_la(integer c, object x) -- convert Latin atom or sequence to upper or to lower case integer d d='a' - 'A' if c then return x - (x >= 'a' and x <= 'z') * d else return x + (x >= 'A' and x <= 'Z') * d end if end function -- case_la() global function recode(object f, sequence m) -- recode Russian text from one encoding to another one integer c,r,i,o,l sequence F l=1 i=m[1] if i='d' then i=1 elsif i='w' then i=2 elsif i='k' then i=3 elsif i='i' then i=4 elsif i='m' then i=5 elsif i='u' then i=6 else i=0 end if o=m[2] if o='d' then o=1 elsif o='w' then o=2 elsif o='k' then o=3 elsif o='i' then o=4 elsif o='m' then o=5 elsif o='l' then o=6 -- ਡ⥫쭮 ⨭ elsif o='u' then o=7 -- utf-8 else o=0 end if if not i or not o then puts(1,"\n invalid recodeing mode") abort(1) end if if atom(f) then c=find(f,codes[i]) if c then return codes[o][c] else return f end if else if o != 7 and i != 6 then -- ⮢ ஢ for j=1 to length(f) do c=f[j] r=c if c>=128 then c=find(c,codes[i]) if c then f[j]=codes[o][c] else f[j]=r end if end if end for else -- utf-8 F={} if o=7 then -- to utf-8 for j=1 to length(f) do c=f[j] r=c if c > 127 then c=find(c,codes[i]) if c then F&=codes[8][c] F&=codes[7][c] end if else F&=r end if end for else-- from utf-8 while l<= length(f) do c=f[l] r=c if c > 127 then l+=1 if c= '' then if l <= length(f) then c=f[l] end if c=find(c, codes[7][1..39]) if not c then c=f[l] c = find(c, codes[7][41..50]) if c then c+= 40 end if end if elsif c = '' then if l <= length(f) then c=f[l] end if c = find(c, codes[7][51..66]) if not c then c= f[l] if c = '' then c=40 end if else c+=50 end if end if if c then F &= codes[o][c] end if else F &= r end if l+=1 end while end if f=F end if return f end if end function -- recode() -- global constant -- "ab" stands for "alphabet" -- pure Latin, ASCII ab_az = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz", -- Russian, cp 866, DOS (OEM) encoding ab_ru_d = "񆦇", -- Russian, cp 1251, Windows (ANSI) encoding ab_ru_w = "娸", -- Russian, cp koi8-r, UNIX/Linux encoding ab_ru_l = "ų", -- Russian, cp iso-8859-5, ISO encoding ab_ru_i = "бѲҳӴԵաַ׸عٺڻۼܽݾ޿", -- Russian, cp MAC, Macintosh encoding ab_ru_m = "ކ" -- Add yours native alphabets here for needed code pages and use them global function case_xx(integer c, object x, sequence alphabet) integer A, a sequence table table = repeat(0,256) for i=1 to length(alphabet) - 1 by 2 do A = alphabet[i] a = alphabet[i+1] if c then table[A]= A table[a]= A else table[A]= a table[a]= a end if end for if atom(x) then if x then x = table[x] if x then x = x end if end if else for i=1 to length(x) do a = x[i] if a then if table[a] then x[i] = table[a] end if end if end for end if return x end function -- case_xx() -- usage: -- text = case_xx(1, text, alphabet) -- upper case -- text = case_xx(0, text, alphabet) -- lower case -- text - sequence with your text. -- alphabet - sequence with alphabet for the text's language and code page, -- you need to add this sequence below using pure Latin as an example. -- To type your alphabet for DOS code page use the edit.com or ed.ex editor. -- To type your alphabet for Windows code page use the NotePad editor. ---------------------------------------- -- Igor N. Kachan, kinz@peterlink.ru -- 11.06.2005 -- 28.02.2006 -- 06.03.2011