-- 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