Java: Loading Resource Bundle File with UTF-8

I have found out all my previous problems now, thank you all for your assitance with this...
During the time we have worked so solve our problem with UTF-8 charset we have found new problem with this?
I don't know if this is the right forum to put this up, if not please let us know where to go with this?
I have prepared both Eclipse (JSP Files) and GlassFish to run all my files in charset UTF-8. Then i got my
resource bundle files(property files) to use UTF-8 encoding. Everything looks fine in my text editor. Then
when i upload these pages every character retrieved from my resource bundles look garbled. This is because
Java loads property files using ISO 8859-1 character encoding.
This is a problem from Sun i have read on the internet!
Note: that in JDK 1.6, you can use PropertyResourceBundle constructor to take a Reader which uses UTF-8 encoding.
please have a look at these links for more info:
[http://www.kai-mai.com/node/128]
[http://java.sun.com/javase/6/docs/api/java/util/PropertyResourceBundle.html]
Note: PropertyResourceBundle can be constructed either from an InputStream or a Reader, which represents a property file.
Constructing a PropertyResourceBundle instance from an InputStream requires that the input stream be encoded in ISO-8859-1.
In that case, characters that cannot be represented in ISO-8859-1 encoding must be represented by Unicode Escapes,
whereas the other constructor which takes a Reader does not have that limitation.
What i have read and understand is that the real solution to the problem is: Get the fmt lib to use a Reader instead of an
InputStream. Alternativly if it works get a ResourceBundle instead of creating one that is wrong all the time? I have to create
my own ResourceBundle instead of using my own fmt lib wich i cannot trust in a way any more. Is this right or am i comletly wrong?
My WebTexts files, en, sv and ry are my resource property bundles. To be able to read them i will use resource property bundle reader.
Fmt lib gives me this but it seems that it inciates this in an InputStream (wich is looked to iso-8859-1) instead of a reader who can
read UTF-8 without no problem. So can i get my fmt lib to change this or not, anybody have an idea about this???

Torleif wrote:
Ok, i know there are a few ways of doing this already. The problem is that i have no idea how to use these different problem solving issues. First we have the;
1. native2ascii command line utility.
2. use the XML properties format.
3. other ways of converting from iso-8859-1 to utf-8.
The last one i have tried already but i never get this to work. So after knowing of 2 standardized solutions you choose to implement your own non-standard soltion? That's usually not a good idea until you've verified that the standardized solution don't help.
This is also not the best solution to the problem i have to say. This way i will have both properties files and source files to work with and that is to much i think. Either i will use the native2ascii command or use XML properties format like you say here. I need some more insight in how these two work only because i have no idea my self.Uhm .. read [the documentation|http://java.sun.com/javase/6/docs/api/java/util/Properties.html]? loadFromXML/storeToXML work pretty much exactly the same as load/store, except they handle XML. Try it, look at what it produces, learn.
Could you please help and explain how to use either this native2ascii command line work or how this XML format properties would work for me. Please i need guidance here with this!!![native2ascii is documented as well|http://java.sun.com/javase/6/docs/technotes/tools/windows/native2ascii.html].
If you have a specific question after reading those, feel free to ask here.
You really have to work on your Google-fu, it seems to be too weak.

Similar Messages

  • Using utf-8 in jsp with resource bundle files(Farsi Language) Help !

    Hi,
    I am using jdeveloper and struts and i have a resourcce bundle file that i am writing in Farsi in it.
    my jsp looks like this :
    <%@ page contentType="text/html;charset=UTF-8"%>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <html:form action="IndexAction.do" method="POST" enctype="UTF-8">
    <% request.setCharacterEncoding("UTF-8");%>
    <bean:message key="button.add" /><!-- i get the key from the bundle here-->
    i have saved the bundle file in utf-8 and i have tried native2ascii on it as well.
    i also have response.setContentType("text/html; charset=UTF-8"); in my action file.my browser setting is also utf-8.
    but still i get garbage chars in jsp.
    any idea ?
    thax
    reza

    hello
    i have problem whit write farsi in jsp.
    the charecter is destroy.
    please help me.
    thanks

  • How To Change Resource Bundle file's data from Java Class

    Hi
    i have used below code for accessing Resource Bndle from Java Class but here i also want to make change in a particular key and its value.
    please let me know the code i should use to make changes in Resource Bundle file's key and value and saving the same in the file.
    package test;  import java.util.Enumeration;
    import java.util.ResourceBundle;
    public class ResourceBundleTest {
    public static void main(String[] args) {
    ResourceBundle rb = ResourceBundle.getBundle("test.bundletest.mybundle");
    Enumeration <String> keys = rb.getKeys();
    while (keys.hasMoreElements()) {
    String key = keys.nextElement();
    String value = rb.getString(key);
    System.out.println(key + ": " + value);
    Thanks

    With further debugging, I noticed the following line only works in integrated WLS but not in standalone WLS
    resourceBundle = ResourceBundle.getBundle("com.myapp.MyMappings");
    I confirmed the corresponding properties file was included properly in the EAR file but the standalone WLS failed to find the properties file at runtime.
    Why did the standalone WLS class loader (must be the same as the integrated WLS) failed to find the properties file deployed under the WEB-INF/classes path in the EAR file?
    The above line was in a POJO class which has the same classpath as the properties file ie. com.myapp.MappingManager.class.
    It was strange that the class loader could load the POJO class but unable to find the com.myapp.MyMappings.properties in the same classpath!!!
    Is this a bug in standalone WLS?
    Edited by: Pricilla on May 26, 2010 8:52 AM
    Edited by: Pricilla on May 26, 2010 9:01 AM

  • Character encoding in resource bundle files

    I am developing a multilingual site, using resource bundle files. The problem I'm having is that, while the jsp file is save in UTF-8, and the contentType="text/html; charset=UTF-8", the foreign characters in the bundle files don't display properly unless I save them as "windows-1252". If I copy the text and paste it into the jsp file, it displays correctly.
    How can I make the text from the bundle files display the same as the text in the jsp document itself when both files are saved as UTF-8? I'm surprised it doesn't do this by default.

    Because resource bundles (the PropertyResoureceBundle class in particular) doesn't know anything about JSP or HTML page encodings. All that class knows is that it needs to load a properties file from the local (server-side) file system. (BTW, if you are using Struts MessageResources, it works the same way). Anyway, it doesn't read the file every time you call for a resource property String, it reads it 1 time, and 1 time only when you call new ResourceBundle().
    The API docs (in java.util.Properties) specified that properties files are read using the ISO8895-1 encoding, actually, not the Windows-1252 or whatever the OS defines. So if you store text that's using a different encoding then ISO8895-1, it's going to read the chars incorrectly.
    native2ascii converts things to ASCII using Unicode escapes, as I said. (Although, maybe it saves as ISO8895-1, I forget..., or maybe you should specify the output encoding.... you'd have to read the docs on that tool, cuz there's no command-line help.) This is sort-of an exception to the ISO8895-1 thing, in a sense, as all ASCII chars are the same as the first 127 chars of ISO8895-1, so it doesn't matter really.
    So in short, it doesn't assume it's in the default Windows encoding, it assumes it's in ISO8895-1. But since the API docs specifically say so, you should abide by those rules.
    As for "getting around the problem", yes, it does, actually. See, whatever it reads in that Unicode escaped ASCII text is converted properly to Strings in Java, which are 16-bit Unicode characters, which cover nearly every character set around (English, Chinese, Japanese, Arabic, Cyrillic, etc). When it's in that form, the chars are the Unicode chars and that's it. That's all they need to be. Encodings are only important when writing (and reading back) to files or other byte streams. You have to read in with the same encoding it was written under, otherwise the conversion is not going to be correct (with a few exceptions, but not many).
    So that creates a Unicode String in Java, and when you write that to a JSP page or servlet, the output writer used knows from the content type you specified in the page declaration (UTF-8 is typically recommended because it's an efficent way to deal with Unicode chars, particularly in HTML, where most of the HTML tag content is still ASCII text), so it encodes the strings in that encoding.
    Get it?

  • Where does the resources bundle files need to be

    Hi All,
    Does any of you knows where all the custom resources bundle files that will be used on BCC need to be?
    I have something like this:
    BCC module /src/com/mycompany/resources/WebAppResources.properties
    But when I try to use it
    This happens
    javax.servlet.jsp.JspException: An error occurred while evaluating custom action attribute "title" with value "${activity.description}": An error occurred while getting property "description" from an instance of class atg.bizui.activity.GenericActivity (java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key manageLoyaltyProgram.description)
    I am trying to use it on a activity that will be used in the ActivityManager:
    This is what I have
    <resource-bundle>com.mycompany.resources.WebAppResources</resource-bundle>
    Do you know if I am missing somehting or putting the files on a wrong location?
    Regards,
    Obed

    Hi Shaik,
    The title of for the source is added http://i.imgur.com/a6WVxsW.png but when I click on it it throws this exception:
    javax.servlet.jsp.JspException: An error occurred while evaluating custom action attribute "value" with value "${activity.displayName}": An error occurred while getting property "displayName" from an instance of class atg.bizui.activity.GenericActivity (java.util.MissingResourceException: Can't find resource for bundle j
    ava.util.PropertyResourceBundle, key emanageLoyaltyProgram.displayName)
    meaning that the properties file is on the classpath, but my genericActivities.xml file is not able to read the properties file.
    Any suggestion?
    Regards,
    Obed

  • Please : WWC-43273 - ContainerException: Unable to load resource bundle

    Please Help :(
    Development Environment:
    Application : Hello World Portlet
    OAS : 10.1.2.0.2 Installed on LocalHost
    Development Tool : JDeveloper 10.1.3.2.0
    Portal Server : 10.1.4 Installed on LocalHost
    I have followed following Tutorial for the same : http://www.oracle.com/technology/obe/obe1014portal/standards_portlets/stdsplts.htm
    My EAR WSDL (http://localhost/HelloWorld/portlets?WSDL) in OAS is working perfectly fine yeilding following output :
    <?xml version = '1.0' encoding = 'UTF-8'?>
    <wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:bind="urn:oasis:names:tc:wsrp:v1:bind" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="urn:oasis:names:tc:wsrp:v1:wsdl">
    <import namespace="urn:oasis:names:tc:wsrp:v1:bind" location="http://www.oasis-open.org/committees/wsrp/specifications/version1/wsrp_v1_bindings.wsdl"/>
    <wsdl:service name="WSRPService">
    <wsdl:port binding="bind:WSRP_v1_Markup_Binding_SOAP" name="WSRPBaseService">
    <soap:address location="http://infra:80/HelloWorld/portlets/WSRPBaseService"/>
    </wsdl:port>
    <wsdl:port binding="bind:WSRP_v1_ServiceDescription_Binding_SOAP" name="WSRPServiceDescriptionService">
    <soap:address location="http://infra:80/HelloWorld/portlets/WSRPServiceDescriptionService"/>
    </wsdl:port>
    <wsdl:port binding="bind:WSRP_v1_Registration_Binding_SOAP" name="WSRPRegistrationService">
    <soap:address location="http://infra:80/HelloWorld/portlets/WSRPRegistrationService"/>
    </wsdl:port>
    <wsdl:port binding="bind:WSRP_v1_PortletManagement_Binding_SOAP" name="WSRPPortletManagementService">
    <soap:address location="http://infra:80/HelloWorld/portlets/WSRPPortletManagementService"/>
    </wsdl:port>
    </wsdl:service>
    </wsdl:definitions>
    However when i try to access the same via Register Provider wizard in Portal Server 10.1.4 i get this exception.
    An error occurred during the call to the WSRP Provider: Java stack trace from root exception:
    java.rmi.ServerException: Internal Server Error (java.lang.RuntimeException: oracle.webdb.wsrp.server.ContainerException: Unable to load resource bundle "portlet.resource.CHelloWorldBundle")
    at com.sun.xml.rpc.client.StreamingSender._raiseFault(StreamingSender.java:384)
    at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:245)
    at oracle.webdb.wsrp.WSRP_v1_ServiceDescription_PortType_Stub.getServiceDescription(WSRP_v1_ServiceDescription_PortType_Stub.java:63)
    at oracle.webdb.wsrp.client.design.v1.OraWSRP_v1_ServiceDescription_PortType.getServiceDescription(Unknown Source)

    Found the solution:
    I needed to choose the Servlet 2.3/JSP 1.2 (J2EE 1.3) when creating my JSR268 Portlet.
    Also the second change I needed to make was to use J2SE ver. 1.4.2_12. To do this change the default j2se ver. of JDeveloper(i.e ver. 1.5) from project properties > libraries node > edit/change j2se definitions screen and select java.exe from j2se1.4.2_12/bin

  • Manually loading resource bundles

    Hi,
    i'm trying to use the .properties files to configure my app.
    This is outside of the general localization discussions and i'm
    running into a few problems. i'm building an internal global tool
    and want to use property files to define the specific views and
    attributes for each section. in my project i have a folder called:
    properties and in it there is a folder for en_US.
    inside of en_US i have two folders, one for each section: UPD
    and BBS. each of those folders have their own config.properties
    file.
    the compile directives look like this:
    -locale=en_US -allow-source-path-overlap=true
    -source-path=properties/{locale}/UPD,properties/{locale}/BBS
    in my application there is a drop down with BBS and UPD
    options. I want to switch to the correct bundle when a user changes
    the dropdown values. attached is the code for the dropdown and the
    switching.
    can someone tell me how to point to the correct bundles?
    Thanks,
    d

    I've tried referencing the default properties file that gets created with a new Visual Java Faces project called Bundle.properties which is in the base directory. This works and it does not complain about a default language en_AU.
    I've searched the directory files for anything thats different about the default properties file but can't find it referenced???
    Currently I'll run with this option but is there any setting I'm missing that prevents me referencing a resource-bundle file in another folder which might cause this error?

  • How to load unicode data files with fixed records lengths?

    Hi!
    To load unicode data files with fixed records lengths (in terms of charachters and not of bytes!) using SQL*Loader manually, I found two ways:
    Alternative 1: one record per row
    SQL*Loader control file example (without POSITION, since POSITION always refers to bytes!)<br>
    LOAD DATA
    CHARACTERSET UTF8
    LENGTH SEMANTICS CHAR
    INFILE unicode.dat
    INTO TABLE STG_UNICODE
    TRUNCATE
    A CHAR(2) ,
    B CHAR(6) ,
    C CHAR(2) ,
    D CHAR(1) ,
    E CHAR(4)
    ) Datafile:
    001111112234444
    01NormalDExZWEI
    02ÄÜÖßêÊûÛxöööö
    03ÄÜÖßêÊûÛxöööö
    04üüüüüüÖÄxµôÔµ Alternative2: variable length records
    LOAD DATA
    CHARACTERSET UTF8
    LENGTH SEMANTICS CHAR
    INFILE unicode_var.dat "VAR 4"
    INTO TABLE STG_UNICODE
    TRUNCATE
    A CHAR(2) ,
    B CHAR(6) ,
    C CHAR(2) ,
    D CHAR(1) ,
    E CHAR(4)
    ) Datafile:
    001501NormalDExZWEI002702ÄÜÖßêÊûÛxöööö002604üuüüüüÖÄxµôÔµ Problems
    Implementing these two alternatives in OWB, I encounter the following problems:
    * How to specify LENGTH SEMANTICS CHAR?
    * How to suppress the POSITION definition?
    * How to define a flat file with variable length and how to specify the number of bytes containing the length definition?
    Or is there another way that can be implemented using OWB?
    Any help is appreciated!
    Thanks,
    Carsten.

    Hi Carsten
    If you need to support the LENGTH SEMANTICS CHAR clause in an external table then one option is to use the unbound external table and capture the access parameters manually. To create an unbound external table you can skip the selection of a base file in the external table wizard. Then when the external table is edited you will get an Access Parameters tab where you can define the parameters. In 11gR2 the File to Oracle external table can also add this clause via an option.
    Cheers
    David

  • How can we load a flat file with very, very long lines into a table?

    Hello:
    We have to load a flat file with OWB. The problem is that each of the lines in the file might be up to 30.000 characters long (up to 1.000 units of information in each line, 30 characters long each)
    Of course, our mapping should insert these units of information as independent rows in a table (1.000 rows, in our example).
    We do not know how to go about it. We usually load flat files using table functions, but we am not sure that they will be able to cope with these huge lines. And how should we pivot those lines? Will the Pivot operator do the trick? Or maybe we should pivot those lines outside the database before loading them?
    We are a bit lost. Any suggestion would be appreciated.
    Regards
    Edited by: [email protected] on Oct 29, 2008 8:43 AM
    Edited by: [email protected] on Oct 29, 2008 8:44 AM

    Yes, well, we could define a 1.000 column external table, and then map those 1.000 columns to the Pivot operator… perhaps it would work. But we have been investigating a little bit, and we think that we have found a better solution: there is a unix utility called “fold”. This utility can split our 30.000 character lines in 1.000 lines, 30 characters long each: just what we needed. Then we can load the resulting file using an external table.
    We think this is a much better solution that handling 1.000 columns in the external table and in the Pivot operator.
    Thanks for your help.
    Regards
    Edited by: [email protected] on Oct 29, 2008 10:35 AM

  • How to load a flat file with lot of records

    Hi,
    I am trying to load a flat file with hundreds of records into an apps table. when i create the process and deploy it onto the console it asks for an input in an html form. why does it ask for an input when i have specified the input file directory in my process? is there any way around tis where in it just reads all the records from the flat file directly??is custom queues anyway related to what I am about to do?any documents on this process will be greatly appreciated.If any one can help me on this it will be great. thank you guys....

    After deploying it, do you see if it is active and the status is on from the BPEL console BPEL Process tab? It should not come up to ask for input unless you are clicking it from the Dashboard tab. Do not click it from the Dashboard. Instead you should put some files into the input driectory. Wait few seconds you should see the instances of the BPEL process is created and start to process the files asynchrously.

  • How to load a flat file with utf8 format in odi as source file?

    Hi All,
    Anybody knows how we can load a flat file with utf8 format in odi as source file.Please everybody knows to guide me.
    Regards,
    Sahar

    Could you explain which problem are you facing?
    Francesco

  • Load one text file with 12 periods' data into 12 different periods at once?

    Hi guys,
    In one swoop, can we load one .txt file with 12 periods of data into 12 different periods?
    The scenario:
    Budget data is required for monthly comparative reporting with actuals, so we have 12 periods in our Budget version.
    From a non-SAP system we get one .txt file containing 12 periods worth of budget data,
    - it is in the correct format (and we don't want to create risk by opening and editing it) so it is loaded into each period and the other 11 periods of irrelevant data are obviously ignored.
    Some extra tasks (such as validation, cashflow calculations) are then performed per period.
    Because this has to be repeated 12 times, this can be a time consuming process
    We now have multiperiod monitor functionality (from EHP2) and I see how it works for the automatic tasks (very well).
    I'm aware that the guide says that manual tasks will be ignored during the automatic run, this is true.
    However, if I remember correctly EC-CS used to allow it with upoad files, so i was expecting it in BCS 6.02
    - is there anyway to load a file containing 12 periods worth of data into 12 individual periods in all at once?
    (NB we still have an improvement to the previous situation, the user can scroll between periods more quickly and load the file 12 times, then go back to the start and run all auto tasks at once)..
    One thought was to use a file server location with a hardcoded filename but his would require work beyond my expertise.
    All suggestions welcome

    Hi
    I wil suggest mapping the path based on a common location is the best way and then map the same logically in the Upload method
    If you are using Citrix then it becomes all the more easy to have a commmon location
    Rgds
    Dheeraj

  • [svn:fx-trunk] 7661: Change from charset=iso-8859-1" to charset=utf-8" and save file with utf-8 encoding.

    Revision: 7661
    Author:   [email protected]
    Date:     2009-06-08 17:50:12 -0700 (Mon, 08 Jun 2009)
    Log Message:
    Change from charset=iso-8859-1" to charset=utf-8" and save file with utf-8 encoding.
    QA Notes:
    Doc Notes:
    Bugs: SDK-21636
    Reviewers: Corey
    Ticket Links:
        http://bugs.adobe.com/jira/browse/iso-8859
        http://bugs.adobe.com/jira/browse/utf-8
        http://bugs.adobe.com/jira/browse/utf-8
        http://bugs.adobe.com/jira/browse/SDK-21636
    Modified Paths:
        flex/sdk/trunk/templates/swfobject/index.template.html

    same problem here with wl8.1
    have you sold it and if yes, how?
    thanks

  • How to compare and edit Resource bundle file using java programe

    Hi All
    I have two resource bundle with key, value and some comments. I need to write a java code to compare both of the values of the keys and if the values are different then i want to replace the second value with the first value.
    Its a programe which will udpate the second file with the first file values.
    I tried using Properties class but it didnt worked because when i am saving the file using store method it removes all the comments and the order of text also got disturbed.
    How I need to do this any help appriciated.
    Please elt me know if someone needs more info.
    Thanks in advance.

    Let's assume the ini file is a mapping type storage (key=value) so lets use Properties object. (works with java 1.4 & up)
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.Properties;
    public class Test {
         private static Properties props;
         public static void main(String[] args) throws IOException {
              File file = new File("test.ini");//This is out ini file
              props = new Properties();//Create the properties object
              read(file);//Read the ini file
              //Once we've populated the Properties object. set/add a property using the setProperty() method.
              props.setProperty("testing", "value");
              write(file);//Write to ini file
         public static void read(File file) throws IOException {
              FileInputStream fis = new FileInputStream(file);//Create a FileInputStream
              props.load(fis);//load the ini to the Properties file
              fis.close();//close
         public static void write(File file) throws IOException {
              FileOutputStream fos = new FileOutputStream(file);//Create a FileOutputStream
              props.store(fos, "");//write the Properties object values to our ini file
              fos.close();//close
    }

  • Loading resource bundle

     

    Hi,
              Try putting it in classfiles directory.Do not keep copies of it in any
              other directories...It is working in my case so it should in u r cases
              too...
              Better luck..
              Sameer Gijare
              Joseph Benavidez wrote:
              > I'm having the same problem. I have resource bundles (techincally,
              > property files) in my classpath (not the servlet classpath)
              > that loaded fine with the ResourceBundle.getBundle() method
              > under 5.0 beta 2, but the call seems to be broken now.
              >
              > j.joseph benavidez
              > [email protected]
              >
              > > Philippe Renon wrote:
              > >
              > > Hi,
              > >
              > > I use the following line of code to load a resource bundle from within
              > > a jsp page.
              > >
              > > <%
              > > ResourceBundle bundle = ResourceBundle.getBundle("WebBundle",
              > > request.getLocale());
              > > %>
              > >
              > > I keep getting java.util.MissingResourceException: Can't find bundle
              > > for base name WebBundle, locale fr
              > > If have three files (WebBundle.properties, WebBundle_fr.properties
              > > and WebBundle_fr_FR.properties) , but
              > > I'm not sure where I'm supposed to place these files, so they can be
              > > loaded from the servlet.
              > >
              > > Philippe.
              > >
              > > PS: I use WL 5.1 & J2SE 1.3
              

Maybe you are looking for

  • Getting some photos on my ipod, but do not show up in photos folder

    I wanted to put some photos of my artwork on my ipod, but when I go to look in the photos section of the ipod, they are not there, & I tried making a folder for them, & that is not showing up, when I look in windows explore they are there under ipod

  • HT5610 How do i authorize my imac to play my itunes music?

    Does anyone know how I would authorize my imac as a computer that can play my itunes music?

  • Project management advice

    I'm not experienced when it comes to the best way of organizing a project. My current project uses footage of about 11 hours and my movie is going to be about 3 hours. I have it in one project with 19 sequences and plan to output to 3 disks.  I think

  • Employee Technicals Requirements in the side of ECC 6.0

    Hi forum      Recently i wrote one note in SAP about one problem i have, the thing is that i have one BAPI (HRXSS_SER_GETMENUDATA) that has one parameter more in some ERPs. and ESS 603 use it      Summarizing this note: I have this version of ESS ins

  • Cursor in InDesign way too big

    Hi, My cursor in InDesign is super huge. Checked previous discussions on the matter, but none seem to help with the problem. I'm using Windows 8, and my size of all items is already at a 100 % in the Control Panel. Another problem is that when workin