cancel
Showing results for 
Search instead for 
Did you mean: 

Russian Characters in JSP

former_member187444
Participant
0 Kudos

Hi Friends,

What encoding do have to i use for Russian characters in jsp.

And i will use this jsp as a ivew of portal.

Thanks in Advance

Best Regards

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

May be your property file isn't use UTF-8.

former_member187444
Participant
0 Kudos

I try this algo

if user's language is russian then i use hard code in javascript alert if not, i get alert's message from properties file.

thanks

Former Member
0 Kudos

Hi Eray,

Did you ever resolve this problem? I have the same problem with Jsp iViews and French characters. We dont want to use the unicode escape codes as we have lots of text in the properties files.

I have an OSS message open with SAP but no response yet....

Cheers,

Steve

former_member187444
Participant
0 Kudos

Hi Steve;

I have solved it as:

I check user language, if it is russian then i use such as


<%if(lang.equals("ru")){%>
 if (confirm("&#1042;&#1099;&#1073;&#1088;&#1072;&#1085;&#1085;&#1099;&#1077; &#1089;&#1086;&#1086;&#1073;&#1096;&#1077;&#1085;&#1080;&#1103; &#1073;&#1091;&#1076;&#1091;&#1090; &#1091;&#1076;&#1072;&#1083;&#1077;&#1085;&#1099;")) {
<%}else{%>	
  if (confirm("<%=Utilities.getString("Selected_messages_will_be_deleted")%>")) {
<%}%>

<i>Note:Utilites is my resource bundle</i>

Sigiswald
Contributor
0 Kudos

Hi Steve,

Note that ResourceBundle.getBundle usually returns a java.util.PropertyResourceBundle instance and that the supported format and encoding is that of java.util.Properties, which eventually only supports <b>ISO-8859-1</b> when reading from a file (as of J2SE 5, Properties can also be read from an XML file, which supports other encodings as well). Other characters should be represented by Unicode escapes, which can easily be done using the native2ascii tool. So I'm afraid there's currently no standard workaround for the ISO-8859-1 limitation, unless you create your own implementation of (the abstract) java.util.ResourceBundle or something similar.

Kind regards,

Sigiswald

Former Member
0 Kudos

Hi Sigiswald,

Thanks for your reply. We do have a lot of EP5 iViews that correctly display our French and Dutch characters, running on the same EP6.0 SP14 instance as part of the same application. How can they work correctly and native EP6 iViews not work then?

Cheers,

Steve

Sigiswald
Contributor
0 Kudos

Hi Steve,

I agree it doesn't make sense that you have no problems with the EP56 iViews and only with the EP6 iViews. BTW, what kind of iView are you exactly using? Can you access the underlying jsp directly instead of going through the iView?

As mentioned above, in case you want to enforce the response encoding of the content of the jsp page to be UTF-8, you can use this page directive at the top of your jsp page:

<%@ page contentType="text/html; charset=UTF-8" %>

Maybe also check your browser configuration (in IE: Page/View > Encoding > Auto-Select)?

Do you also have problems with hardcoded non-ASCII characters in the jsp page (the EURO SIGN is a perfect test case; \u20AC) or only with (unescaped) characters read from a ResourceBundle?

You say it's working for EP5 iViews, but not for EP6 iViews. What happens if you connect the EP5 iView to the (jsp)application currently connected to the EP6 iView and vice versa? The question is whether the problem is related to the iView or, as I would expect, the underlying application (jsp or properties file).

I doubt this answer helps a lot, but I'm afraid it requires some more analysis to pinpoint the exact problem. As I know from experience, character encoding issues are often hard to deal with...

Kind regards,

Sigiswald

Former Member
0 Kudos

Hi Sigiswald,

iViews are JSPDynPage iViews.

Can I access the underlying JSP directly? Not sure what you mean here but I can directly edit the JSP page code if that was what you meant?

I've tried the page directive, but this makes no difference.

Hardcoded escape codes work fine, and are the only way we have found to overcome the problem, although we have a lot of labels and paragraphs of text in our resource bundles so it makes it very hard to maintain and get external translators to translate properly.

We have a single application consisting of 20 or so iViews. All were EP5 iviews running on EP5 originally, then we upgraded to EP6 and had to change some of them to EP6 such as the layout page and login page. The others remained in the EP5 structure/format and are maintained in Eclipse 2.1.0 rather than NWDS. All the Localization.properties files are UTF-8 encoding and happily save/display correctly in Eclipse and NWDS.

IE encoding is set to auto as you suggest.

I was thinking that perhaps its something to do with the runtime engine for EP5 being different to EP6 (at least I assume it is?) and it handles the properties files in a different way regarding encoding.

SAP Development Support are on the case. I cant imagine that this is how the product works because it must be impossible for French users to have to use unicode escape codes in their text?

Thanks again for your comprehensive reply!

Cheers,

Steve

Former Member
0 Kudos

Sigiswald,

If you reply to my original thread, /thread/416218 [original link is broken], I can award you some points.

Cheers,

Steve

former_member187444
Participant
0 Kudos

I have such an problem now!

I get russian words from a properties file regarding to users' language.

For anything in jsp russian words seems ok except javascript.

If i get words from properties file and alerts in javascripts, those words are damaged.

I use such as in javascript function

alert ("<%=Utilities.getString("Please,_select_message(s)_first")%>");

and i initilaze properties file

com.sap.security.api.IUser user =
        com.sap.security.api.UMFactory.getAuthenticator().
        getLoggedInUser(request,response);
java.util.Locale currentLocale = user.getLocale();
java.util.ResourceBundle Utilities = 
           java.util.ResourceBundle.getBundle("com/res/MultiLang", currentLocale);

Similarly how can i see russian characters in javascript's alert using language file.

<i>Note: I use UTF-8 for encoding</i>

Thanks in advance...

<b>Eray</b>

former_member182372
Active Contributor
former_member187444
Participant
0 Kudos

Hi again;

I tried this page before but alert messages are hard coded. If i put such as

alert("russian something") 

it works fine but if i get messages from properties file it doesnt work.

Thanks

former_member182372
Active Contributor
0 Kudos

<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>

former_member187444
Participant
0 Kudos

Thanks For your reply,

i am trying

former_member187444
Participant
0 Kudos

I have to use .properties file.

i prepare properties language file and i write this code below


java.util.Locale currentLocale = user.getLocale();
java.util.ResourceBundle Utilities = java.util.ResourceBundle.getBundle("com/sap/engine/res/MultiLang", currentLocale);

But i couldnt get russian.what do have to more?

former_member182372
Active Contributor
0 Kudos

Use http://code.cside.com/3rdpage/us/javaUnicode/converter.html to get unicode and put in properties file something like

SUBMIT=\u041E\u0442\u043F\u0440\u0430\u0432\u0438\u0442\u044C