Yeah, compatibility with existing data is one of the cases where you have to deal with this stuff.
Thel, issue you'll face, then, is just what encodings are available. I don't know what ones are available, but here's the list of the only ones REQUIRED to be available: US-ASCII, ISO-8859-1, UTF-8, UTF-16BE, UTF-16LE, UTF-16 And US-ASCII is a subset of UTF-8. This will give you what's available on the platform: http://developer.android.com/intl/de/reference/java/nio/charset/Charset.html#availableCharsets() (It will contain duplicates under different names, so you probably want to stuff all the values into a hash table to eliminate duplicates, before generating a list for any menu). If you have to, you can implement your own. Note that Java is using the term "charset" here a bit incorrectly, to cover both the set of characters (which it calls Character.Subset) and encoding+character set (which is what you have here). It doesn't expose encoding systems directly. However, when you get to WebView.loadData(...) -- you STILL have to use UTF-8! Confusing, eh? That's because it takes a string, and by the time you have a string, you are already in the Unicode world. Do *NOT* try to read non-UTF-8 data as UTF-8! It may appear to work when you test it. Until you hit just the wrong data, and it dies, probably after you release your product. You have to supply the proper encoding when you read the data into the string. If it's coming from a file, you'll want to do supply your encoding like this: InputStream raw_in = new FileInputStream(file); try { BufferedReader in = new BufferedReader(new InputStreamReader(raw_in, encoding)); ... } finally { raw_in.close(); } However, since loadData(...) requires the entire string at once, unless you're feeding it small pages, rather than en entire book, you won't be able to handle large books. In that case, I suggest copying it to a file, converting to UTF-8 in the process, and using WebView.loadUrl(String) instead. On Thu, Mar 25, 2010 at 9:50 PM, brijesh masrani <[email protected]> wrote: > The Problem is that i am making a Ebook reader so and there is no facility > like file writing so i cant force user to write in UTF-8 encoding and i have > to show text of all encoding because i cant force user to choose the > encoding type.. > > > On Thu, Mar 25, 2010 at 7:57 PM, Bob Kerns <[email protected]> wrote: > >> If you add HTML tags, you also have to convert the text, converting < and >> > and & to <, >, and &, respectively. >> >> But there's an easier way. Instead of >> webview.loadData(page, "text/html", "utf-8") -- use "text/plain" instead, >> and leave off the tags. >> >> >> On Thu, Mar 25, 2010 at 5:13 AM, brijesh masrani < >> [email protected]> wrote: >> >>> Hello >>> >>> I am reading a txt file using Stringbuffer and try to show it in webview >>> by adding simple html tags (<html><Body>"My txt content"</html></Body>) >>> but it is not showing Spacial characters so can u please help me or any >>> other way to show txt file in Web Browser.... >>> >> >> \ -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en To unsubscribe from this group, send email to android-developers+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.

