problem with spanish characters in android app

by bobetko » Thu, 19 May 2011 04:33:33 GMT


Sponsored Links
 I have issue with spanish characters in java string. I have a content
RSS feed and when i try to transform it to java object using
InputStreamReader, I get outputs like "cmo" which should be "cmo".
This is happening with other spanish characters like

 =   =   =   =   = 

and more..

How can I convert these characters to proper spanish characters?

Here is how my InputStreamReader looks like:

Reader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"),
1024);

I tried doing my own method like this:
public static String fixSpanish(String s)
    {
        s = s.replaceAll("", "");
        s = s.replaceAll("", "");
        s = s.replaceAll("", "");
        s = s.replaceAll("", "");
        s = s.replaceAll("", "");
        Log.d(TAG, s);
        return s;
    }

But, this didn't work. None of search combinations are ever found.
Any ideas?

Thanks in advance

-- 



Re: problem with spanish characters in android app

by Kostya Vasilyev » Thu, 19 May 2011 04:50:32 GMT


 Is your input stream really UTF-8?

I would dump the data you're getting somewhere as bytes (or look at it 
in the debugger if it's small) and double check the character set.


The accented "o" is 0xF3 in ISO-8859-1

 http://www.fileformat.info/info/unicode/char/f3/index.htm 

In UTF-8, the 0xF3 is a special character prefix, used by, among other 
things, mathematical symbols:


 http://download.oracle.com/docs/cd/B10501_01/server.920/a96529/appb.htm #952448

-- Kostya

19.05.2011 0:33, bobetko :
I have issue with spanish characters in java string. I have a content RSS feed and when i try to transform it to java object using InputStreamReader, I get outputs like "cmo" which should be "cmo". This is happening with other spanish characters like = = = = = and more.. How can I convert these characters to proper spanish characters? Here is how my InputStreamReader looks like: Reader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"), 1024); I tried doing my own method like this: public static String fixSpanish(String s) { s = s.replaceAll("", ""); s = s.replaceAll("", ""); s = s.replaceAll("", ""); s = s.replaceAll("", ""); s = s.replaceAll("", ""); Log.d(TAG, s); return s; } But, this didn't work. None of search combinations are ever found. Any ideas? Thanks in advance
-- Kostya Vasilyev -- http://kmansoft.wordpress.com --


Sponsored Links


Other Threads

1. Keep activity running while in "sleep" mode

> I am newer to Android development and I have a app that needs to run a

Use AlarmManager. Keep your service stopped normally, and use an alarm to
wake up the device and run your code.

http://tinyurl.com/y9mttv5

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
Android App Developer Books: http://commonsware.com/books.html

2. Custom ClassLoader - Urgent!

Hi guys,

I'm trying to replace the class loader with my custom class loader. I
don't want to replace the default functionality, only add new
functionality.

The goal is that every new class instance that calls:
getClass().getResourceAsStream(resName)

will load the requested resource in the way I define in my
CustomClassLoader.

My code contains the following:
ClassLoader classLoader = new CustomClassLoader
(ClassLoaderTestActivity.class.getClassLoader()); // Create my own
class loader with the default class loader as parent.

Thread.currentThread().setContextClassLoader(classLoader); // This is
just for testing

TestClass test = (TestClass)Class.forName("com.test.TestClass", true,
classLoader).newInstance() ;

Since the 'test' TestClass instance is created with reference to the
new class-loader, I'd expect that after this line executes,
test.getClass().getClassLoader() will return an instance of
CustomClassLoader, but I always get the default PathClassLoader
returned.

My only assumption so far is that since my CustomClassLoader only
overrides specific functionality, and the ClassLoader that actually
calls 'defineClass' is the default one, the TestClass instance is
never associated with my ClassLoader.

Any help would be highly appreciated.
Thanks,
Lior

3. Android Performance Monitoring..

4. bug: Android emulator keeps timing out

5. how can I launch my own activity from Home screen?

6. Intent filter for text/calendar ?

7. mouse pointer position