JSF encoding problem with Russian

Hi,
I am new to JSF, trying to build prototype i18n JSF app with MyFaces 1.1.5
Mostly care about IE6/7, do not officially support other browsers.
I do have resource bundles, it is localized and internationalized.
So user is supposed to work in either English or Russian.
It all works except a few issues:
1) When user enters something in Russian in inputText field on the first page,
trying to pass it to the next page via managed bean.
But instead of showing it in Russian, it shows some garbled text in outputText or outputLabel: Îëåã
FF3 & Chrome show it as: Олег [&#xxxx, where xxxx us a 4 digits]
It does pick up labels from correct bundle on the next page, so locale is changed correctly.
Actually, when I switch locale on the same first page, getting the same problem (after it's refreshed).
Seems to work OK with Spanish
Is that incorrect Cyrillic encoding, JSF encoding or broken Unicode or locale?
How can we fix that ?
Less important issues:
2) When we switch locale (correct values in bundles), on the screen it can not change currencyCode, currencySymbol, TimeZone,
it always shows the first one it picked, although dateTime and Number formatting changes correctly;
3) In IE6 "alt" tag attribute produces garbled characters in Russian (black vertical squares), looks like IE6 bug; FF3 & Chrome work fine.
Please help !
TIA,
Oleg.

For 1, you are not passing the characters in the correct encoding from one page to the next when you pass the parameter (most likely).

Similar Messages

  • Cp-1251 utf-8 converting: problems with russian letters

    Hello every one!
    I have faced a major problem in cp-1251 to utf8 string convertion (in Windows):
    String result2 = new String(result.getBytes("utf8"), Charset.forName("cp-1251"));Everything works fine, but there is a problem with russian letter И (10th letter in the alphabeth).
    cp-1251 byte code of И is 200
    The right byte code for И in utf-8 is : 208 152, but I recieve the byte code 208 63 for И. So there must be some mistake.
    So, when i try to read this string, i face a problem with wrong utf-8 charset...
    I tried this code on Debian, everything works fine.
    I will be glad if you are capable of helping me.
    Thank you.
    Edited by: smikler on Sep 27, 2009 10:25 AM
    Edited by: smikler on Sep 27, 2009 10:27 AM

    Your code makes no sense.
    You're taking a String and asking for it to be turned into a stream of bytes according to the UTF-8 character encoding. And then you're giving these bytes back and asking to have them interpreted back into characters using the CP-1251 character encoding. This is bound to fail, because the bytes aren't in CP-1251 - they're in UTF-8 as you requested.
    The very concept of changing the character encoding of a String is meaningless. Strings in Java are represented in Unicode. It's only when you convert to and from bytes (using the two methods you've used) that you worry about encoding/decoding.
    So, why not describe what you're actually trying to achieve?

  • Planning problems with russian language during refresh application

    Hello all ))
    I have problems with Planning during refresh my Application with Essbase.
    I intsalled Essbase on RHEL4 and set ESSLANG=Russian_Russia.ISO-8859-5@Default also I set locale on ru_RU.iso88595
    Ater that I installed Planning on Solaris 9 which uses Oracle RDBMS with NLS_CHARACTERSET=AL32UTF8 and set locale on server to ru_RU.iso88595
    Now I can create dementions, members on russion language in Essbase without problems also I can create dementions,members,etc on russian language in Planning. But if I create demention or member in Planning on Russian languge and ) try refresh my Application with Essbase I give follow error
    "=====(HspCubeCreation.java)sQueryString:?Application=Test1
    com.hyperion.planning.olap.EssbaseException: (1060010)
    at com.hyperion.planning.olap.HspEssbaseOutlineAPI.EssAddMemberEx(Native Method)
    at com.hyperion.planning.olap.HspCubeRefreshTask.addChildren(Unknown Source)
    at com.hyperion.planning.olap.HspCubeRefreshTask.addMembers(Unknown Source)
    at com.hyperion.planning.olap.HspCubeRefreshTask.addDimensionsAndMembers(Unknown Source)
    at com.hyperion.planning.olap.HspCubeRefreshTask.buildOutlines(Unknown Source)
    at com.hyperion.planning.olap.HspCubeRefreshTask.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)"
    Why it's happened?
    Please anybody help me

    since march 5 we are on planning 9.3.1.1 and also having problems with refreshing:
    com.hyperion.planning.HspCubeRefreshInProgressException: Cannot complete your request because the database is being refreshed.
         at com.hyperion.planning.HspJSImpl.lockApp(I)V(Unknown Source)
         at com.hyperion.planning.HyperionPlanningBean.lockApp()V(Unknown Source)
         at HspSecurityFilter.Handle(Ljavax.servlet.http.HttpServletRequest;Ljavax.servlet.http.HttpServletResponse;)V(Unknown Source)
         at HspSecurityFilter.doPost(Ljavax.servlet.http.HttpServletRequest;Ljavax.servlet.http.HttpServletResponse;)V(Unknown Source)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:225)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:127)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:272)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:165)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3150)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:1973)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1880)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1310)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:179)
    com.hyperion.planning.HspCubeRefreshInProgressException: Cannot complete your request because the database is being refreshed.
         at com.hyperion.planning.olap.HspCubeRefreshTask.run()V(Unknown Source)
         at java.lang.Thread.run()V(Unknown Source)
    anyone a idea?

  • Problems with Russian characters in BB Bridge

    Some time ago my contact list on BB 9800 was updated using Desktop software for Mac. Some of contacts were written in Russian. Same updates were made for MemoPad as well in the same manner. Everything was good on the smartphone side before I made an attempt to sync my phone with Playbook. Both sections refused to sync! After removing manually all contacts and memos with Russian font, the sync went normal again. There are a lot of problems with Playbook, which cost me my time and money. This was just one of them... Why not to say it clear - do not try to sync Russian characters?

    Same problem when I use Chinese.
    The only thing we can do now is to wait for an update! Which is hopefully make the Playbook worth something!

  • Problems with russian characters

    I need to localize my application to russian language and i have problems with their special characters. I use Graphics.drawString method and unicode escape sequences and this works fine on phones like SE, Nokia and Siemens. But some phones are not able to display these characters (Motorola, Sharp, Samsung). Do u know any other way how to draw these characters on problematic phones listed above?
    thanx for any hint

    thanx for hint, but i'm not familliar with this stuff in j2me. could u described it in more details, please?

  • Encoding Problems with WRT300N V2

    Hello guys,
    i have following problem:
    I have a WRT300n Router and it seems to have problems with WPA2 encoding. I have 2 different deviceses (a SMC Ethernet Bridge and a PS3) trying to connect to my Linksys wireless router. No chance in WPA2 mode but when I try in WEP-Mode, both devicec can connect to it.
    Are there known encoding problems?
    Any idea what i can do?

    It is able to use. But my router always drops the connection. WEP is no problem, but ... what about low security and Wirless N is not enabled ??

  • Encoding problem with XSL

    Hi,
    I have problems when printing the result of processing XML with an XSL that contains locale specific chars.
    Here is a sample:
    XML :
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <ListePatients>
    <Patient>
    <Nom>Zeublouse</Nom>
    <NomMarital/>
    <Prinom>Agathe</Prinom>
    </Patient>
    <Patient>
    <Nom>Stick</Nom>
    <NomMarital>Laiboul</NomMarital>
    <Prinom>Ella</Prinom>
    </Patient>
    <Patient>
    <Nom>`ihnotvy</Nom>
    <NomMarital/>
    <Prinom>Jacques</Prinom>
    </Patient>
    </ListePatients>
    XSL :
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html"/>
    <xsl:template match="*|/"><xsl:apply-templates/></xsl:template>
    <xsl:template match="text()|@*"><xsl:value-of select="."/></xsl:template>
    <xsl:template match="/">
    <HTML>
    <HEAD>
    <META http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
    <TITLE>Liste de patients</TITLE>
    </HEAD>
    <BODY>
    <xsl:apply-templates select='ListePatients'/>
    </BODY>
    </HTML>
    </xsl:template>
    <xsl:template match='ListePatients'>
    <TABLE>
    <xsl:for-each select='Patient'>
    <xsl:sort select='Nom' order='ascending' data-type='text'/>
    <TR TITLE='`ihnotvy'>
    <TD> <xsl:value-of select='Nom'/> </TD>
    <TD> <xsl:value-of select='NomMarital'/> </TD>
    <TD> <xsl:value-of select='Prinom'/> </TD>
    </TR>
    </xsl:for-each>
    </TABLE>
    </xsl:template>
    </xsl:stylesheet>
    Test program (from Oracle sample) :
    import java.net.URL;
    import java.io.*;
    import oracle.xml.parser.v2.DOMParser;
    import oracle.xml.parser.v2.XMLDocument;
    import oracle.xml.parser.v2.XMLDocumentFragment;
    import oracle.xml.parser.v2.XSLStylesheet;
    import oracle.xml.parser.v2.XSLProcessor;
    public class XSLSampleOTN
    * Transforms an xml document using a stylesheet
    * @param args input xml and xml documents
    public static void main (String args[]) throws Exception
    DOMParser parser;
    XMLDocument xmldoc, xsldoc, out;
    URL xslURL;
    URL xmlURL;
    try
    if (args.length != 2)
    // Must pass in the names of the XSL and XML files
    System.err.println("Usage: java XSLSampleOTN xslfile xmlfile");
    System.exit(1);
    // Parse xsl and xml documents
    parser = new DOMParser();
    parser.setPreserveWhitespace(true);
    // parser input XSL file
    xslURL = DemoUtil.createURL(args[0]);
    parser.parse(xslURL);
    xsldoc = parser.getDocument();
    // parser input XML file
    xmlURL = DemoUtil.createURL(args[1]);
    parser.parse(xmlURL);
    xmldoc = parser.getDocument();
    // instantiate a stylesheet
    XSLStylesheet xslSS = new XSLStylesheet(xsldoc, xslURL);
    XSLProcessor processor = new XSLProcessor();
    // display any warnings that may occur
    processor.showWarnings(true);
    processor.setErrorStream(System.err);
    // Process XSL
    XMLDocumentFragment result = processor.processXSL(xslSS, xmldoc);
    // print the transformed document
    result.print(System.out);
    // an other way to print, it doesn't print the same !!!!
    processor.processXSL(xslSS, xmldoc, System.out);
    catch (Exception e)
    e.printStackTrace();
    When printing the transformed document with DocumentFragment.print() it work fine but when using processXSL(xslSS, xmldoc, System.out) it don't works for locale specific chars and a second <META> balise appears, Why ?
    with DocumentFragment.print(), it's Ok :
    <HTML>
    <HEAD>
    <META http-equiv="Content-Type"
    content="text/html; charset=iso-8859-1"/>
    <TITLE>Liste de patients</TITLE>
    </HEAD>
    <BODY>
    <TABLE>
    <TR TITLE="`ihnotvy">
    <TD>`ihnotvy</TD>
    <TD/>
    <TD>Jacques</TD>
    </TR >
    <TR TITLE="`ihnotvy">
    <TD>Stick</TD>
    <TD>Laiboul</TD>
    <TD>Ella</TD>
    </TR>
    <TR TITLE="`ihnotvy">
    <TD>Zeublouse
    </TD>
    <TD/>
    <TD>Agathe</TD>
    </TR>
    </TABLE>
    </BODY>
    </HTML>
    With processXSL(xslSS, xmldoc, System.out), it's not Ok :
    <HTML>
    <HEAD>
    <META http-equiv="Content-Type" content="text/html">
    <META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <TITLE>Liste de patients</TITLE>
    </HEAD>
    <BODY>
    <TABLE>
    <TR TITLE="C C)C(C.C/C4C6C9">
    <TD>C C)C(C.C/C4C6C9</TD>
    <TD></TD>
    <TD>Jacques</TD>
    </TR>
    <TR TITLE="C C)C(C.C/C4C6C9">
    <TD>Stick</TD>
    <TD>Laiboul</TD>
    <TD>Ella</TD>
    </TR>
    <TR TITLE="C C)C(C.C/C4C6C9">
    <TD>Zeublouse</TD>
    <TD></TD>
    <TD>Agathe</TD>
    </TR>
    </TABLE>
    </BODY>
    </HTML>
    TIA
    Didier
    null

    Two other problems with XSL and print:
    first one :
    XSL :
    <SCRIPT langage="Javascript" type="text/javascript" src="scripts/erreur.js"></SCRIPT>
    DocumentFragment.print() produce :
    <SCRIPT langage="Javascript" type="text/javascript" src="scripts/erreur.js"/>
    => IE5.5 don't load the file !!, it required syntaxe like <SCRIPT ...></SCRIPT> to load.
    the second one :
    XSL:
    <TD><IMG src="images/menuleft.gif"/></TD>
    DocumentFragment.print() produce :
    <TD>
    <IMG src="images/menuleft.gif">
    </TD>
    processXSL(xslSS, xmldoc, System.out) produce :
    <TD><IMG src="images/menuleft.gif">
    </TD>
    Why a cariage return ?? it cause prisentation failure when you want to specifie the size off the cell !!
    TIA
    Didier
    null

  • Encoding problem with Application adapter for OEBS

    Hello All!
    We going to pass value via app adapter from EBS Forms to Content Server page. Link to documentation Configuring the Managed Attachments Solution - 11g Release 1 (11.1.1)
    We have done all setting, and this function is working now .
    It is good working with English letters and numbers, but when we try to use Cyrillic we have a problem with Encoding in Content server page.
    Data on Oebs table use ''CL8ISO8859P5'', but service xml for adapter has allays a title with  charset=utf-8
    System are:
    OEBS 12.1.3
    Webcenter Content 11.1.1.6
    Adapter 11.1.1.6 + patch 16463891
    Could you help us?

    Hi Denis ,
    Try this solution :
    1) Log on to the APPS EBS schema and re-create the AXF_SOAPCall function using the following SQL:
    create or replace
    function AXF_SOAPCall (url varchar2, soapmsg varchar2, secure varchar2, walletid varchar2, walletpass varchar2) return varchar2 as
    http_req utl_http.req;
    http_resp utl_http.resp;
    response_env varchar2(32767);
    v_newcharset VARCHAR2(40 BYTE) :='UTF8';
    v_Dbcharset VARCHAR2(40 BYTE);
    v_Raw1 RAW(32767);
    v_Stmt1 VARCHAR2(6000 BYTE);
    begin
    v_newcharset := 'AMERICAN_AMERICA.'|| v_newcharset ;
    v_Dbcharset := 'AMERICAN_AMERICA.'||utl_i18n.map_charset(fnd_profile.value('ICX_CLIENT_IANA_ENCODING'),0,1);
    v_Raw1 := UTL_RAW.CAST_TO_RAW (soapmsg);
    v_Raw1 := UTL_RAW.CONVERT (v_Raw1,v_newcharset,v_Dbcharset);
    if ( secure = 'true' or secure = 'TRUE' ) then
    utl_http.set_wallet (walletid, walletpass);
    end if;
    http_req := utl_http.begin_request(url , 'POST', utl_http.HTTP_VERSION_1_1);
    utl_http.set_header(http_req, 'Content-Type', 'text/xml; charset=utf-8');
    utl_http.set_header(http_req, 'Content-Length', utl_raw.length(v_Raw1));
    utl_http.write_raw(http_req, v_Raw1);
    http_resp := utl_http.get_response(http_req);
    utl_http.read_text(http_resp, response_env);
    dbms_output.put_line('Response: ');
    dbms_output.put_line(response_env);
    utl_http.end_response(http_resp);
    return response_env;
    end;
    2) Log on to the EBS and confirm that you can now open the Managed Attachments window for all records & forms, regardless of the use (& length) of multibyte string values.
    This was caused by multibyte characters used with non UTF-8 language strings .
    I presumed that you are seeing that when "Managed Attachments" option through the ZOOM button from an E-Business Suite (EBS) forms, nothing happens.If you have a support id then check the following note : 1409703.1 from MyOracleSupport portal.
    Hope this helps.
    Thanks,
    Srinath

  • Problem with russian tags in english version of iTunes.

    I'm using english language in MacOS:
    end when I adding music to iTunes with russian tags and names it make it look like this:
    but when I make russian as first language...
    it becomes ok:
    Question is: How to fix it, and listen russian music in iTunes with normal names and tags?
    Thank you.

    It may be you need to convert the tags to Unicode.  This app may help:
    http://www.macupdate.com/app/mac/15953/id3mod

  • Problem with Russian characters in Firefox on Mac OS X 10.5

    Hi everybody,
    I installed the latest version of Firefox (2.0.0.9) on Mac OS X 10.5(Leopard) on my iMac (Core 2 Duo, 2.16GHz). Now when I change the language option to Russian (in Mac OSX) and type in Firefox search box (in the top right corner) I see only question marks ("????") instead of russian characters. The same happens when I open Google page in the browser and type there. Also if I bookmark a web page that contains russian character in the title, it also have "????..." instead.
    However on some web pages, where I need to provide input the russian letters do show up. Also it works fine in Safari.
    I didn't have this kind of issue on previous versions of Mac OSX (Tiger) and Firefox. When I installed Firefox there everything just worked fine and I didn't have to change any settings. I still have my bootable drive with this configuration and when I run it everything is fine. I tried to compare language settings and Firefox preferences and character encoding settings in Tiger and Leopard, but I don't see any difference.
    I played with character encoding settings in Firefox, but that didn't fix the problem. Is it the problem of Leopard? Does anybody have the same issue? Any help is appreciated.
    Thank you.
    - Dmitri

    I think this is a FireFox problem, you need to ask them to fix it and use another browser (or perhaps the Russian version of Firefox) in the meantime.
    http://discussions.apple.com/thread.jspa?messageID=5668950&#5668950

  • Problem with Russian translation

    Yesterday I took in to rent a movie "we Millers"! However, no Russian track. Just a silent movie!
    This is not the first time Same problems i'd have with "Machetto killes" movie
    . What's the matter?

    Welcome to the Apple Community.
    Select the content which is causing a problem and use the 'Report a problem' button in Your Purchase History on your computer.
    Currently, if your purchase happens to be your most recent purchase you will need to click the large ‘Report A Problem’ button under the list of previous purchases in order to reveal the ‘Report A Problem’ link for your recent purchase. If your purchase is listed as a previous purchase use the small arrow on the left side of its listing.
    Alternatively you can use the receipt email to report a problem.

  • Encoding problem with convert and CLOB involving UTF8 and EBCDIC

    Hi,
    I have a task that requires me to call a procedure with a CLOB argument containing a string encoded in EBCDIC. This did not go well so I started narrowing down the problem. Here is some SQL to illustrate it:
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE 10.2.0.4.0 Production
    TNS for Solaris: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    SQL> select value from v$nls_parameters where parameter = 'NLS_CHARACTERSET';
    VALUE
    AL32UTF8
    SQL> select convert(convert('abc', 'WE8EBCDIC500'), 'AL32UTF8', 'WE8EBCDIC500')
    output from dual;
    OUT
    abc
    SQL> select convert(to_char(to_clob(convert('abc', 'WE8EBCDIC500'))), 'AL32UTF8', 'WE8EBCDIC500') output from dual;
    OUTPUT
    ╒╫¿╒╫¿╒╫¿
    So converting to and from EBCDIC works fine when using varchar2, but (if I am reading this right) fails when involving CLOB conversion.
    My question then is: Can anyone demonstrate how to put correct EBCDIC into a CLOB and maybe even explain why the examples do what they do.

    in order to successfully work with xmldb it is recommended that you use 9.2.0.4
    and above. Its seems to have lower version.
    Okay now related to the problem , if your data that you want to send to the attributes are not greater than 32767, then you can use the pl/sql varchar2 datatype to hold the data rather then CLOB and overcome this problem.
    here is the sample. use function with below pl/sql to return the desired output.
    SQL> declare
      2   l_clob     CLOB := 'Hello';
      3   l_output   CLOB;
      4  begin
      5    select  xmlelement("test", xmlattributes(l_clob AS "a")).getclobval()
      6      into l_output from dual;
      7  end;
      8  /
      select  xmlelement("test", xmlattributes(l_clob AS "a")).getclobval()
    ERROR at line 5:
    ORA-06550: line 5, column 44:
    PL/SQL: ORA-00932: inconsistent datatypes: expected - got CLOB
    ORA-06550: line 5, column 3:
    PL/SQL: SQL Statement ignored
    SQL> declare
      2   l_vchar     varchar2(32767) := 'Hello';
      3   l_output   CLOB;
      4  begin
      5    select  xmlelement("test", xmlattributes(l_vchar AS "a")).getclobval()
      6      into l_output from dual;
      7    dbms_output.put_line(l_output);
      8  end;
      9  /
    <test a="Hello"></test>
    PL/SQL procedure successfully completed.

  • Encoding Problems with 16:9

    hi, just started creating 16:9 projects, however i dont think idvd likes 16:9 as anytime i try t burn it fails and says that "there was a problem during encoding" anyway else experience this?

    This may be of assistance to you and others experiencing the wonderfully enigmatic " Encoding Video - There was an error during movie encoding. "
    SHORT VERSION of SOLUTION: Downloaded Handbrake. Converted source video using Handbrake's default settings. Imported resulting videos into iDVD. Everything worked.
    LONG VERSION of SOLUTION: I have a few 16:9 mp4 videos that I was attempting to burn onto a relatively simple DVD. No matter what theme I chose, I received the encoding error. After reading a number of other posts on the subject, on a lark, I thought I would try to change the encoding of the movies to some other format. Turns out this solved the problem in a roundabout way. Handbrake (http://handbrake.fr/?article=download) was key to the solution. I tried converting to MKV first; that didn't work. Then I noticed something. When I chose the mp4 original and left Handbrake with default settings, the specifications for the source video showed 1280x720, but the specifications for the output video showed 1278x720. I converted the mp4 video to ... well ... mp4 (Handbrake's default format). Handbrake's resulting file had an m4v extension, but I don't think that has any relevance. So, back in iDVD, I imported the new versions of the video and everything worked. I hope that is of some assistance to you.

  • Problems with Russian, Ukrainian etc. characters in Polish InDesign CS4

    Hi everyone,
    I'm a new user of InDesign CS4 (Polish version). Mostly i'm using Garamond Pro for setting text -- there is no Russian characters. Who know which one font has Russian, Ukrinian, Bulgarian Oldslavic etc. characters?
    thanks in advance!
    Maks

    If you're using Windows, there is an incredibly useful utility Babelmap that has the tool you need: "List all the fonts installed on my system that support the text I have on my clipboard". I used to use it all the time.
    I very much doubt that you have many fonts already installed on your system that support Old Slavic, unless you've installed them yourself. Bulgarian coverage is better, but still not common. If you'd like I can post some links to the pages where links to the type foundries working in these scripts are often posted. If you're not already familiar with it, Paratype is probably going to be your first stop.

  • Encoding problem with xml

    Hello,
    I'm trying to save on disk an xml with utf-8 codification and compressed with "gzip" algorithm. For some reasons, I have to use a BufferedWriter, then I must convert the byte[] to String.
    Afterwards, I read this document and I try to decompress it and save on a String variable.
    If I do all this process using utf-8 encoding, the decompressing process throws an exception: Not in GZIP format.
    But if I use iso-8859-1, then everything works OK.
    I don't understand why using iso works, and why using utf-8 does not work (when the webservice specification says that the xml documents are sent in utf-8).
    The code is the following (the static "myCharset" is the key: when I set iso works, and setting utf-8 does not work):
    public class testCompress
    public static String xmlOutput     = "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><consultaCiudadesPorPaisResponse xmlns=\"http://tempuri.org/\"><consultaCiudadesPorPaisResult><xml funcion=\"ConsultaCiudadesPorPais\" xmlns=\"\"><ROK>TRUE</ROK></xml></consultaCiudadesPorPaisResult></consultaCiudadesPorPaisResponse></soap:Body></soap:Envelope>";
    public static String myCharset     = "iso-8859-1";
    // Writes the compressed document to disk.
    public static void writeDocument() throws Exception
      BufferedWriter writer = null;
      try 
       // Compress the "xmlOutput" converting this string to bytes using "utf-8" as specification says (in "compress" method)
       // Afterwards, I convert this byte[] to String using "myCharset".
       String compressedFile = new String(CompressionService.compress(xmlOutput, "utf-8", "gzip", 8), myCharset);
       // And write to disk using "myCharset" as the encoding used by "OutputStreamWriter".
       writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("c:/cache"), myCharset), 8192);
       writer.write(compressedFile);
      catch (Exception e) { throw e; }
      finally
        if (writer != null)
         try { writer.close(); writer = null; } catch (IOException ioe) {}
    // Reads the compressed document from disk.
    public static byte[] readDocument() throws Exception
      BufferedReader reader = null;
      StringBuilder sb           = new StringBuilder();
      char[] buffer           = new char[8192];
      try
       // Open the file using "myCharset" for reading chars.
       reader = new BufferedReader(new InputStreamReader(new FileInputStream("c:/cache"), myCharset));
       int numchars = 0;
       while ((numchars = reader.read(buffer, 0, 8192)) >= 0) sb.append(buffer, 0, numchars);
       // And return the result as a byte[] encoded with "myCharset".
       return (sb.toString().getBytes(myCharset));
      catch (Exception e) { throw e; }
      finally
       if (reader != null)
        try { reader.close(); } catch (IOException ioe) {}
    public static void main(String[] args) throws Exception
      writeDocument();
      byte[] file = readDocument();
      // DECOMPRESS FAILS IF myCharset = "utf-8", and works if myCharset = "iso-8859-1"
      System.out.println(com.vpfw.proxy.services.compress.CompressionService.decompress(file, "utf-8", "gzip", 8));
    }

    Okay, here's what's happening. You created a byte[] by encoding some text as UTF-8, then you ran that byte[] through a gzip deflater. The result is binary data that can only be understood by a gzip inflater; to any other software it just looks like garbage. Now you're taking a randomly-chosen encoding and pretending the binary data is really text that was encoded with that encoding.
    Most encodings have limits on what kinds of input they can accept. For example, US-ASCII only uses the low-order seven bits of each byte; any byte with a value larger than 127 is invalid. When the encoder encounters such a byte, it inserts the standard replacement character, U+FFFD, in that spot. When you try to decode the string again as US-ASCII, the replacement character is what you see in that position; the original byte value is lost. In UTF-8, the bytes have to conform to [certain patterns|http://en.wikipedia.org/wiki/UTF-8#Description]; for example, any byte with a value greater than 127 has to be part of a valid two-, three- or four-byte sequence.
    ISO-8859-1 is different. It's a single-byte encoding like ASCII, but it uses all eight bits of every byte. Furthermore, every possible byte value (0..255) maps to a character, so you can throw any random byte at it and tell it the byte represents a character, and it will believe you. Some of those values may map to control characters that would look like garbage if you displayed them, but they're valid. That means you can re-encode the string as ISO-8859-1 and get back the exact byte sequence you started with.
    So that's why your code "works" when you use ISO-8859-1, but I strongly recommend that you find another way; making binary data masquerade as text is dangerously fragile. Why do you have to use a Writer anyway? Is it for transmission over a medium that only accepts text data? If so, you should use a Base64 encoder or similar tool that's designed for that purpose.

Maybe you are looking for