Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
Developer
Posts: 77
Registered: ‎11-03-2009
My Device: 9810 Torch
My Carrier: VIPnet

BrowserField can not display utf-8 characters - revisited - Croatian characters

Hello to everyone reading this post.

 

I did quite extensive research on this topic, and I think I found and hit all the related articles to this issue more than 10 times, wandering if I missed something... but it seems to me I haven't.

 

The problem is with showing SOME UTF-8 characters in the BrowserField.

I used both 5.0 and 6.0 BrowserField (jre) versions, and still not solution to the problem.

 

On the back-end side I have MySQL db, with UTF-8 encoding.

I connect to the database, extract data (bytes), and convert it into String,

by way of using command: content = new String(data, "UTF-8");

 

When in debugger, content shows data appropriate, with all the Croatian (Slovenian, Bosnian, Serbian...) characteres being shown appropriately.

However, when this string is being attached to the BrowserField, instead of Croatian charcters, there are question marks signs (?).

Meanwhille, German and Hungarian charcters are being shown correctly.

 

I have enclosed a code-snippet, where actual data retreival process is replaced by a string, which should be displayed on the screen.

 

 

public void run() {
	BrowserField _bf2;
	BrowserFieldConfig _bfConfig = new BrowserFieldConfig();
	String baseURL = "http://test.racunalo.com/";
	
	_bfConfig.setProperty(BrowserFieldConfig.NAVIGATION_MODE,
			BrowserFieldConfig.NAVIGATION_MODE_POINTER);
	_bfConfig.setProperty(BrowserFieldConfig.JAVASCRIPT_ENABLED,
			Boolean.TRUE);
	_bfConfig.setProperty(BrowserFieldConfig.ALLOW_CS_XHR,
			Boolean.TRUE);
	_bfConfig.setProperty(BrowserFieldConfig.INITIAL_SCALE,
			new Float(1.0));
	_bfConfig.setProperty("Content-Type", "text/plain; charset=utf-8");
	
	_bf2 = new BrowserField(_bfConfig);
	add(_bf2);
	String Test = "Išo medo u dućan, nije rek'o dobar dan," +
			"<P>iš medo van, nisi rek'o dobar dan!" +
			"<P> a sada: Čekić, Šalica, Džem, džep, Žaba, kućica..." +
			"<P>" +
			"Übung, Österreich, amtlich Republik Österreich" +
			"<P>Osztrák Köztársaság" +
			"<P>Ländern Burgenland, Kärnten, Niederösterreich, " +
			"Oberösterreich, Salzburg, Steiermark, Tirol, " +
			"Vorarlberg und Wien, das gleichzeitig Hauptstadt ist. " +
			"Seit 1995 ist Österreich Mitglied der Europäischen Union." +
			"<P> Službeni naziv Österreich potječe od stare " +
			"visokonjemačke riječi Ostarrîchi (istočni reich) " +
			"i kao takvo se prvi put spominje 996. godine.";
	_bf2.displayContent(Test, baseURL);    	    	        
	//_bf2.displayContent(napuniListuRezultata(poveznica), baseURL);
}

 

 

I am expecting to see this:
Išo medo u dućan, nije rek'o dobar dan,
iš medo van, nisi rek'o dobar dan!
a sada: Čekić, Šalica, Džem, džep, Žaba,kućica...

Übung, Österreich, amtlich Republik Österreich
Osztrák Köztársaság
Ländern Burgenland, Kärnten, Niederösterreich,
Oberösterreich, Salzburg, Steiermark, Tirol,
Vorarlberg und Wien, das gleichzeitig Hauptstadt ist.
Seit 1995 ist Österreich Mitglied der Europäischen Union.
Službeni naziv Österreich potječe od stare
visokonjemačke riječi Ostarrîchi (istočni reich) i kao takvo se prvi put spominje 996. godine.


but I am seeing this text in the BrowserField:
I?o medo u du?an, nije rek'o dobar dan,
i? medo van, nisi rek'o dobar dan!
a sada: ?eki?, ?alica, D?em, d?ep, ?aba,ku?ica...

Übung, Österreich, amtlich Republik Österreich
Osztrák Köztársaság
Ländern Burgenland, Kärnten, Niederösterreich,
Oberösterreich, Salzburg, Steiermark, Tirol,
Vorarlberg und Wien, das gleichzeitig Hauptstadt ist.
Seit 1995 ist Österreich Mitglied der Europäischen Union.
Slu?beni naziv Österreich potje?e od stare
visokonjema?ke rije?i Ostarrîchi (isto?ni reich) i kao takvo se prvi put spominje 996. godine.

 

All other fields (LabelFields, buttons, even text created with graphics.drawText is displayed correctly.

 

Am I doing something wrong, or have I found a bug in the device?

 

Thank you for your help and advices,

 

with kind regards,

Hrvoje

 

ps. BlackBerry browser itself displays the characters correctly.

 

 

 

New Developer
Posts: 2
Registered: ‎09-07-2016
My Device: bold
My Carrier: tecnos

Re: BrowserField can not display utf-8 characters - revisited - Croatian characters

public void run() {
BrowserField _bf2;
BrowserFieldConfig _bfConfig = new BrowserFieldConfig();
String baseURL = "http://test.racunalo.com/";

_bfConfig.setProperty(BrowserFieldConfig.NAVIGATION_MODE,
BrowserFieldConfig.NAVIGATION_MODE_POINTER);
_bfConfig.setProperty(BrowserFieldConfig.JAVASCRIPT_ENABLED,
Boolean.TRUE);
_bfConfig.setProperty(BrowserFieldConfig.ALLOW_CS_XHR,
Boolean.TRUE);
_bfConfig.setProperty(BrowserFieldConfig.INITIAL_SCALE,
new Float(1.0));
_bfConfig.setProperty("Content-Type", "text/plain; charset=utf-8");

_bf2 = new BrowserField(_bfConfig);
add(_bf2);
String Test = "Išo medo u dućan, nije rek'o dobar dan," +
"<P>iš medo van, nisi rek'o dobar dan!" +
"<P> a sada: Čekić, Šalica, Džem, džep, Žaba, kućica..." +
"<P>" +
"Übung, Österreich, amtlich Republik Österreich" +
"<P>Osztrák Köztársaság" +
"<P>Ländern Burgenland, Kärnten, Niederösterreich, " +
"Oberösterreich, Salzburg, Steiermark, Tirol, " +
"Vorarlberg und Wien, das gleichzeitig Hauptstadt ist. " +
"Seit 1995 ist Österreich Mitglied der Europäischen Union." +
"<P> Službeni naziv Österreich potječe od stare " +
"visokonjemačke riječi Ostarrîchi (istočni reich) " +
"i kao takvo se prvi put spominje 996. godine.";
_bf2.displayContent(Test, baseURL);
//_bf2.displayContent(napuniListuRezultata(poveznica), baseURL);
}