Android Dictionary (English<->Chinese)

Search for BETA-testers and/or promote your own Application in a decent way.

Postby cabernet1976 » Thu Jan 10, 2008 2:32 am

Thank you, Nitinkcv.
It is very useful to me.
Upload2Flickr's blog: http://upload2flickr.blogspot.com
cabernet1976
Senior Developer
Senior Developer
 
Posts: 154
Joined: Fri Nov 16, 2007 2:34 am
Location: China

Top

Postby Nitinkcv » Thu Jan 10, 2008 7:57 am

Hi,

Did you face any similar problems like me.. could you please help me out?

Thnx
nitin
Nitinkcv
Developer
Developer
 
Posts: 29
Joined: Thu Nov 29, 2007 1:02 pm

Postby cabernet1976 » Fri Jan 11, 2008 4:11 pm

Hi Nitinkcv,

For Chinese language, there are some types of character, i.e. gb2312 character is a type of ANSI, but often we get data from web (i.e by HTTP) is in UTF-8 which is a type of UNICODE.

I just translate UTF-8 data to gb2312 (Chinese character) which is my content's real character, then put the result to edit text, android will display them.

And I have met some problem about display but nevery get UnsupportedEncodingException, my problem is: some English words' international phonetic symbol cannot be displayed in the view. e.g. [wə:d]'s ə cannot be displayed.
Upload2Flickr's blog: http://upload2flickr.blogspot.com
cabernet1976
Senior Developer
Senior Developer
 
Posts: 154
Joined: Fri Nov 16, 2007 2:34 am
Location: China

Postby Nitinkcv » Sat Jan 12, 2008 7:00 pm

Hi,

Thanx for looking into it. Just one query did you ever get the chinese characters displayed in the similar manner like this?


സ and ു etc..



If yes what resolution did you adopt..

Thanx
Nitin
Nitinkcv
Developer
Developer
 
Posts: 29
Joined: Thu Nov 29, 2007 1:02 pm

Postby cabernet1976 » Wed Jan 16, 2008 12:40 pm

Hi Nitinkcv,
Sorry for so late to reply you, I find what your said just now.
I double check my program, and do some modfication. Then get something:
1. If I don't translate the HTTP response whose content is Chinese to gb2312, the program will throw a exception UnsupportedEncodingException which you has asked me before. So the following code is needed:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.                         Reader reader = null;
  2.                         InputSource inputsource = null;
  3.                         try {
  4.                                 reader = new InputStreamReader(inputstream, "gb2312");
  5.                         } catch (UnsupportedEncodingException e) {
  6.                                 Log.e(TAG, "new InputStreamReader UnsupportedEncodingException");
  7.                         } catch (Exception e) {
  8.                                 Log.e(TAG, "new InputStreamReader error");
  9.                         }
  10.                        
  11.                         try {
  12.                                 inputsource = new InputSource(reader);
  13.                         } catch (Exception e) {
  14.                                 Log.e(TAG, "new InputSource error");
  15.                         }
  16.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


2. If I set a invalid chartset for InputStreamReader, i.e. utf-8, I will get like the attached picture.
Attachments
utf-8.JPG
utf-8.JPG (17.36 KiB) Viewed 2685 times
Upload2Flickr's blog: http://upload2flickr.blogspot.com
cabernet1976
Senior Developer
Senior Developer
 
Posts: 154
Joined: Fri Nov 16, 2007 2:34 am
Location: China

Postby cabernet1976 » Wed Jan 16, 2008 12:51 pm

Hi Nitinkcv,

I have tried to use iso-8859-1 to resolve my program's issue (cannot display international phonetic symbol of word),
but failed :(

And I got other thread, hope it will help you.
I do tesing in Firefox, send out this url: http://dict.cn/ws.php?q=word
Then check the response's source code, there is something like what you have said: & # 6 0 1 ;
It will be displayed by Firefox as ə
This is the international phonetic symbol which unable display in my program.
Upload2Flickr's blog: http://upload2flickr.blogspot.com
cabernet1976
Senior Developer
Senior Developer
 
Posts: 154
Joined: Fri Nov 16, 2007 2:34 am
Location: China

Top

Postby papaya » Wed Oct 08, 2008 10:52 am

学习。
papaya
Freshman
Freshman
 
Posts: 8
Joined: Wed Oct 08, 2008 10:15 am

Re: Android Dictionary (English<->Chinese)

Postby deph1lt » Thu May 20, 2010 11:27 am

need help...

i use the source code to build a new dictionary, but i got some problem
i'm using android 2.1 SDK with eclipse

at this sentence

Code: Select all
for (int i=0; i<pronList.getLength(); i++) {
                 Element pronEl = (Element)doc.getElementsByTagName("pron").item(i);
                 String aPron = pronEl.[color=#FF8000]getChildNodes()[/color].item(0).getNodeValue();
                 Log.i(TAG, "pron["+i+"]: "+aPron);
                prons += " ["+aPron+"]";
             }

Code: Select all
String defs = "";
             for (int i=0; i<defList.getLength(); i++) {
                 Element defEl = (Element)doc.getElementsByTagName("def").item(i);
                 String aDef = defEl.[color=#FF0000]getChildNodes()[/color].item(0).getNodeValue();
                Log.i(TAG, "def["+i+"]: "+aDef);
                defs += aDef;
             }


Code: Select all
for (int i=0; i<sentList.getLength(); i++) {
                 Element sentEl = (Element)doc.getElementsByTagName("sent").item(i);
                 String orig =
                    sentEl.getElementsByTagName("orig").item(0).[color=#FF4000]getChildNodes()[/color].item(0).getNodeValue().replace("\n", " ").trim();
                 String trans =
                    sentEl.getElementsByTagName("trans").item(0).[color=#FF0000]getChildNodes()[/color].item(0).getNodeValue().replace("\n", " ").trim();
                 Log.i(TAG, "orig["+i+"]: "+orig);
                 Log.i(TAG, "trans["+i+"]: "+trans);
                 int j = i+1;
                 String aSent = "\n"+j+". "+orig+"\n   "+trans;
                 sents += aSent;
             }


the error at the red color area.

some please guide me.. thanks before..
deph1lt
Once Poster
Once Poster
 
Posts: 1
Joined: Tue May 18, 2010 4:43 am

Top
Previous

Return to Promote your Android Application

Who is online

Users browsing this forum: No registered users and 2 guests