2011-12-13 71 views
12

好吧,如何使泰米尔统一Android中

所以我的问题是,我有一个XML泰米尔语(Unicode)的饲料,我想借此和Android应用程序中显示。

当我尝试这样做时,由于Android没有泰米尔原生支持,必须使用自定义字体。

但是,然后问题出现导致unicode中的渲染是完全不同的。我该如何解决这个问题?

+0

太棒了!什么是努力... –

+3

如果你正在回答你自己的问题,你应该把它作为答案,而不是在问题本身。 –

+0

嗯,它的确如此。遇到同样问题的人可能无法通读您的整个问题,但看不到答案。所以请编辑你的问题,并删除并发布答案作为答案。 :) –

回答

13

我如何解决这个,

我第一次映射到的Unicode的字体Bamini与http://www.ucsc.cmb.ac.lk/ltrl/services/feconverter/帮助。

然后,它只是用Bamini字符替换unicode字符。我将文本发送到该功能并使用Bamini字体显示。

public static String initialize(String text) { 

    text = text.replace("ஸ்ரீ", "="); 
    text = text.replace(",", ">"); 
    text = text.replace("ஜௌ", "n[s"); 
    text = text.replace("ஜோ", "N[h"); 
    text = text.replace("ஜொ", "n[h"); 
    text = text.replace("ஜா", "[h"); 
    text = text.replace("ஜி", "[p"); 
    text = text.replace("ஜீ", "[P"); 
    text = text.replace("ஜு", "[{"); 
    text = text.replace("ஜூ", "[_"); 
    text = text.replace("ஜெ", "n["); 
    text = text.replace("ஜே", "N["); 
    text = text.replace("ஜை", "i["); 
    text = text.replace("ஜ்", "[;"); 
    text = text.replace("ஜ", "["); 
    text = text.replace("கௌ", "nfs"); 
    text = text.replace("கோ", "Nfh"); 
    text = text.replace("கொ", "nfh"); 
    text = text.replace("கா", "fh"); 
    text = text.replace("கி", "fp"); 
    text = text.replace("கீ", "fP"); 
    text = text.replace("கு", "F"); 
    text = text.replace("கூ", "$"); 
    text = text.replace("கெ", "nf"); 
    text = text.replace("கே", "Nf"); 
    text = text.replace("கை", "if"); 
    text = text.replace("க்", "f;"); 
    text = text.replace("க", "f"); 
    text = text.replace("ஙௌ", "nqs"); 
    text = text.replace("ஙோ", "Nqh"); 
    text = text.replace("ஙொ", "nqh"); 
    text = text.replace("ஙா", "qh"); 
    text = text.replace("ஙி", "qp"); 
    text = text.replace("ஙீ", "qP"); 
    text = text.replace("ஙு", "*"); 
    text = text.replace("ஙூ", "*"); 
    text = text.replace("ஙெ", "nq"); 
    text = text.replace("ஙே", "Nq"); 
    text = text.replace("ஙை", "iq"); 
    text = text.replace("ங்", "q;"); 
    text = text.replace("ங", "q"); 
    text = text.replace("சௌ", "nrs"); 
    text = text.replace("சோ", "Nrh"); 
    text = text.replace("சொ", "nrh"); 
    text = text.replace("சா", "rh"); 
    text = text.replace("சி", "rp"); 
    text = text.replace("சீ", "rP"); 
    text = text.replace("சு", "R"); 
    text = text.replace("சூ", "R+"); 
    text = text.replace("செ", "nr"); 
    text = text.replace("சே", "Nr"); 
    text = text.replace("சை", "ir"); 
    text = text.replace("ச்", "r;"); 
    text = text.replace("ச", "r"); 
    text = text.replace("ஞௌ", "nQs"); 
    text = text.replace("ஞோ", "NQh"); 
    text = text.replace("ஞொ", "nQh"); 
    text = text.replace("ஞா", "Qh"); 
    text = text.replace("ஞி", "Qp"); 
    text = text.replace("ஞீ", "QP"); 
    text = text.replace("ஞு", "*"); 
    text = text.replace("ஞூ", "*"); 
    text = text.replace("ஞெ", "nQ"); 
    text = text.replace("ஞே", "NQ"); 
    text = text.replace("ஞை", "iQ"); 
    text = text.replace("ஞ்", "Q;"); 
    text = text.replace("ஞ", "Q"); 
    text = text.replace("டௌ", "nls"); 
    text = text.replace("டோ", "Nlh"); 
    text = text.replace("டொ", "nlh"); 
    text = text.replace("டா", "lh"); 
    text = text.replace("டி", "b"); 
    text = text.replace("டீ", "B"); 
    text = text.replace("டு", "L"); 
    text = text.replace("டூ", "^"); 
    text = text.replace("டெ", "nl"); 
    text = text.replace("டே", "Nl"); 
    text = text.replace("டை", "il"); 
    text = text.replace("ட்", "l;"); 
    text = text.replace("ட", "l"); 
    text = text.replace("ணௌ", "nzs"); 
    text = text.replace("ணோ", "Nzh"); 
    text = text.replace("ணொ", "nzh"); 
    text = text.replace("ணா", "zh"); 
    text = text.replace("ணி", "zp"); 
    text = text.replace("ணீ", "zP"); 
    text = text.replace("ணு", "Z"); 
    text = text.replace("ணூ", "Z}"); 
    text = text.replace("ணெ", "nz"); 
    text = text.replace("ணே", "Nz"); 
    text = text.replace("ணை", "iz"); 
    text = text.replace("ண்", "z;"); 
    text = text.replace("ண", "z"); 
    text = text.replace("தௌ", "njs"); 
    text = text.replace("தோ", "Njh"); 
    text = text.replace("தொ", "njh"); 
    text = text.replace("தா", "jh"); 
    text = text.replace("தி", "jp"); 
    text = text.replace("தீ", "jP"); 
    text = text.replace("து", "J"); 
    text = text.replace("தூ", "J}"); 
    text = text.replace("தெ", "nj"); 
    text = text.replace("தே", "Nj"); 
    text = text.replace("தை", "ij"); 
    text = text.replace("த்", "j;"); 
    text = text.replace("த", "j"); 
    text = text.replace("நௌ", "nes"); 
    text = text.replace("நோ", "Neh"); 
    text = text.replace("நொ", "neh"); 
    text = text.replace("நா", "eh"); 
    text = text.replace("நி", "ep"); 
    text = text.replace("நீ", "eP"); 
    text = text.replace("நு", "E"); 
    text = text.replace("நூ", "E}"); 
    text = text.replace("நெ", "ne"); 
    text = text.replace("நே", "Ne"); 
    text = text.replace("நை", "ie"); 
    text = text.replace("ந்", "e;"); 
    text = text.replace("ந", "e"); 
    text = text.replace("னௌ", "nds"); 
    text = text.replace("னோ", "Ndh"); 
    text = text.replace("னொ", "ndh"); 
    text = text.replace("னா", "dh"); 
    text = text.replace("னி", "dp"); 
    text = text.replace("னீ", "dP"); 
    text = text.replace("னு", "D"); 
    text = text.replace("னூ", "D}"); 
    text = text.replace("னெ", "nd"); 
    text = text.replace("னே", "Nd"); 
    text = text.replace("னை", "id"); 
    text = text.replace("ன்", "d;"); 
    text = text.replace("ன", "d"); 
    text = text.replace("பௌ", "ngs"); 
    text = text.replace("போ", "Ngh"); 
    text = text.replace("பொ", "ngh"); 
    text = text.replace("பா", "gh"); 
    text = text.replace("பி", "gp"); 
    text = text.replace("பீ", "gP"); 
    text = text.replace("பு", "G"); 
    text = text.replace("பூ", "G+"); 
    text = text.replace("பெ", "ng"); 
    text = text.replace("பே", "Ng"); 
    text = text.replace("பை", "ig"); 
    text = text.replace("ப்", "g;"); 
    text = text.replace("ப", "g"); 
    text = text.replace("மௌ", "nks"); 
    text = text.replace("மோ", "Nkh"); 
    text = text.replace("மொ", "nkh"); 
    text = text.replace("மா", "kh"); 
    text = text.replace("மி", "kp"); 
    text = text.replace("மீ", "kP"); 
    text = text.replace("மு", "K"); 
    text = text.replace("மூ", "%"); 
    text = text.replace("மெ", "nk"); 
    text = text.replace("மே", "Nk"); 
    text = text.replace("மை", "ik"); 
    text = text.replace("ம்", "k;"); 
    text = text.replace("ம", "k"); 
    text = text.replace("யௌ", "nas"); 
    text = text.replace("யோ", "Nah"); 
    text = text.replace("யொ", "nah"); 
    text = text.replace("யா", "ah"); 
    text = text.replace("யி", "ap"); 
    text = text.replace("யீ", "aP"); 
    text = text.replace("யு", "A"); 
    text = text.replace("யூ", "A+"); 
    text = text.replace("யெ", "na"); 
    text = text.replace("யே", "Na"); 
    text = text.replace("யை", "ia"); 
    text = text.replace("ய்", "a;"); 
    text = text.replace("ய", "a"); 
    text = text.replace("ரௌ", "nus"); 
    text = text.replace("ரோ", "Nuh"); 
    text = text.replace("ரொ", "nuh"); 
    text = text.replace("ரா", "uh"); 
    text = text.replace("ரி", "up"); 
    text = text.replace("ரீ", "uP"); 
    text = text.replace("ரு", "U"); 
    text = text.replace("ரூ", "&"); 
    text = text.replace("ரெ", "nu"); 
    text = text.replace("ரே", "Nu"); 
    text = text.replace("ரை", "iu"); 
    text = text.replace("ர்", "u;"); 
    text = text.replace("ர", "u"); 
    text = text.replace("லௌ", "nys"); 
    text = text.replace("லோ", "Nyh"); 
    text = text.replace("லொ", "nyh"); 
    text = text.replace("லா", "yh"); 
    text = text.replace("லி", "yp"); 
    text = text.replace("லீ", "yP"); 
    text = text.replace("லு", "Y"); 
    text = text.replace("லூ", "Y}"); 
    text = text.replace("லெ", "ny"); 
    text = text.replace("லே", "Ny"); 
    text = text.replace("லை", "iy"); 
    text = text.replace("ல்", "y;"); 
    text = text.replace("ல", "y"); 
    text = text.replace("ளௌ", "nss"); 
    text = text.replace("ளோ", "Nsh"); 
    text = text.replace("ளொ", "nsh"); 
    text = text.replace("ளா", "sh"); 
    text = text.replace("ளி", "sp"); 
    text = text.replace("ளீ", "sP"); 
    text = text.replace("ளு", "S"); 
    text = text.replace("ளூ", "Sh"); 
    text = text.replace("ளெ", "ns"); 
    text = text.replace("ளே", "Ns"); 
    text = text.replace("ளை", "is"); 
    text = text.replace("ள்", "s;"); 
    text = text.replace("ள", "s"); 
    text = text.replace("வௌ", "nts"); 
    text = text.replace("வோ", "Nth"); 
    text = text.replace("வொ", "nth"); 
    text = text.replace("வா", "th"); 
    text = text.replace("வி", "tp"); 
    text = text.replace("வீ", "tP"); 
    text = text.replace("வு", "T"); 
    text = text.replace("வூ", "T+"); 
    text = text.replace("வெ", "nt"); 
    text = text.replace("வே", "Nt"); 
    text = text.replace("வை", "it"); 
    text = text.replace("வ்", "t;"); 
    text = text.replace("வ", "t"); 
    text = text.replace("ழௌ", "nos"); 
    text = text.replace("ழோ", "Noh"); 
    text = text.replace("ழொ", "noh"); 
    text = text.replace("ழா", "oh"); 
    text = text.replace("ழி", "op"); 
    text = text.replace("ழீ", "oP"); 
    text = text.replace("ழு", "O"); 
    text = text.replace("ழூ", "*"); 
    text = text.replace("ழெ", "no"); 
    text = text.replace("ழே", "No"); 
    text = text.replace("ழை", "io"); 
    text = text.replace("ழ்", "o;"); 
    text = text.replace("ழ", "o"); 
    text = text.replace("றௌ", "nws"); 
    text = text.replace("றோ", "Nwh"); 
    text = text.replace("றொ", "nwh"); 
    text = text.replace("றா", "wh"); 
    text = text.replace("றி", "wp"); 
    text = text.replace("றீ", "wP"); 
    text = text.replace("று", "W"); 
    text = text.replace("றூ", "W}"); 
    text = text.replace("றெ", "nw"); 
    text = text.replace("றே", "Nw"); 
    text = text.replace("றை", "iw"); 
    text = text.replace("ற்", "w;"); 
    text = text.replace("ற", "w"); 
    text = text.replace("ஹௌ", "n`s"); 
    text = text.replace("ஹோ", "N`h"); 
    text = text.replace("ஹொ", "n`h"); 
    text = text.replace("ஹா", "`h"); 
    text = text.replace("ஹி", "`p"); 
    text = text.replace("ஹீ", "`P"); 
    text = text.replace("ஹு", "{`"); 
    text = text.replace("ஹூ", "`_"); 
    text = text.replace("ஹெ", "n`"); 
    text = text.replace("ஹே", "N`"); 
    text = text.replace("ஹை", "i`"); 
    text = text.replace("ஹ்", "`;"); 
    text = text.replace("ஹ", "`"); 
    text = text.replace("ஷௌ", "n\\s"); 
    text = text.replace("ஷோ", "N\\h"); 
    text = text.replace("ஷொ", "n\\h"); 
    text = text.replace("ஷா", "\\h"); 
    text = text.replace("ஷி", "\\p"); 
    text = text.replace("ஷீ", "\\P"); 
    text = text.replace("ஷு", "\\{"); 
    text = text.replace("ஷூ", "\\_"); 
    text = text.replace("ஷெ", "n\\"); 
    text = text.replace("ஷே", "N\\"); 
    text = text.replace("ஷை", "i\\"); 
    text = text.replace("ஷ்", "\\;"); 
    text = text.replace('ஷ', '\\'); 
    text = text.replace("ஸௌ", "n]s"); 
    text = text.replace("ஸோ", "N]h"); 
    text = text.replace("ஸொ", "n]h"); 
    text = text.replace("ஸா", "]h"); 
    text = text.replace("ஸி", "]p"); 
    text = text.replace("ஸீ", "]P"); 
    text = text.replace("ஸு", "]{"); 
    text = text.replace("ஸூ", "]_"); 
    text = text.replace("ஸெ", "n]"); 
    text = text.replace("ஸே", "N]"); 
    text = text.replace("ஸை", "i]"); 
    text = text.replace("ஸ்", "];"); 
    text = text.replace("ஸ", "]"); 
    text = text.replace("அ", "m"); 
    text = text.replace("ஆ", "M"); 
    text = text.replace("இ", "๳"); 
    text = text.replace("ஈ", "<"); 
    text = text.replace("உ", "c"); 
    text = text.replace("ஊ", "C"); 
    text = text.replace("எ", "v"); 
    text = text.replace("ஏ", "V"); 
    text = text.replace("ஐ", "I"); 
    text = text.replace("ஒ", "x"); 
    text = text.replace("ஓ", "X"); 
    text = text.replace("ஔ", "xs"); 

    return text = text.replace("ஃ", "/"); 
} 
4

使用Bamini时的问题是,它不会让你混淆泰米尔语和英语串在一起。它会把所有东西都转换成泰米尔语。结果,英文字符串看起来很荒谬。

举个例子,如果你说என் பேர் மயூரேசன் (Mayooresan),它会被转换为என் பேர் மயூரேசன் (அயலழழசநளயn)

所以我会建议你使用TSCIITABTAM字体。

如果您喜欢convert dynamically I would encourage you to check out the free library我写道动态地转换编码。一旦你导入图书馆,你所要做的只是这一点。

// Initialise the Typeface (assumes TSCII, Bamini, Anjal, TAB or TAM font located inside assets/fonts folder) 
Typeface tf = Typeface.createFromAsset(getAssets(),"fonts/mylai.ttf"); 
// Initialises the TextView 
TextView tv = (TextView)findViewById(R.id.textView1); 
//Setting the Typeface 
tv.setTypeface(tf); 
//Magic happens here ;) encoding conversion 
String TSCIIString = TamilUtil.convertToTamil(TamilUtil.TSCII, "வணக்கம் அன்ரொயிட்"); 
//Setting the new string to TextView 
tv.setText(TSCIIString); 

You can read more on this topic at my answer here

+2

感谢的人:)很高兴看到一个好的斯里兰卡的Android社区 – Hades

+0

不客气@Hades :) –

相关问题