Convert ASCII HttpServletRequest to UTF-8 Correctly (Possible)?

Hi All, Is it possible to convert a request encoded in ASCII that contained UTF-8 Characters to UTF-8 correctly? I am using ATG Dynamo's Application server and for the life of me, it doesn't seem to let me encode the request in anything but ASCII. Anyone have any suggestions.
Thanks,
Rick

i mean how do i get utf-8 "\ue0d0" from parsing in the string "U+e0d0"?The String object written in the form of "\u0000" has no relation with UTF-8 by itself, but the form is the Unicode escape sequence. The encoding UTF-8 is a way of transforming the String object to a byte array in a specified manner.
If you have "U+0000" then you can replace 'U' and '+' with '\' and 'u' with a simple code, though the converted form does not work in a program. What should be done depends on what your aim is.

Similar Messages

  • Is it possible to convert ascii data in binary?

    Hi all.
    In my one table there is a column which contains ascii value. i want to convert it in binary. It it possible in oracle?
    eg field value:1250ÿ it should be 125011111111
    kindly tell how to do this.
    i have tried this using a simple java program but doesnot work for some ascii values.
    thank you

    I created two functions :
    create or replace FUNCTION dec2bin (N IN NUMBER) RETURN VARCHAR2 IS
    binval VARCHAR2(64);
    N2 NUMBER := N;
    BEGIN
    WHILE ( N2 > 0 ) LOOP
    binval := MOD(N2, 2) || binval;
    N2 := TRUNC( N2 / 2 );
    END LOOP;
    RETURN binval;
    END dec2bin;
    And other :
    create or replace function to_ascii( inSource IN VARCHAR2 )
    return varchar2 AS
    ResultString varchar2(381); -- 3 * possible length of source
    TempNumber number;
    begin
    for i in 1..length( inSource ) loop
    TempNumber := dec2bin ( ascii( substr( inSource,i,1 ) ) );
    ResultString := ResultString || trim( to_char(TempNumber,'00000009'));
    end loop;
    return ResultString;
    end;
    Now, in sqlplus : (just to show the binary string)
    column mybin for 9999999999999999999999999999999999999999
    SQL> select to_ascii('g') mybin from dual;
    MYBIN
    01100111
    SQL> select to_ascii('girish') mybin from dual;
    MYBIN
    011001110110100101110010011010010111001101101000
    SQL>Source:http://psoug.org/snippet/Convert-between-Decimal-Binary-Octal-and-Hex_536.htm
    http://www.dbforums.com/oracle/974944-converting-string-binary.html
    Is this you want or something else ?
    Regards
    Girish Sharma

  • Dilemma converting arbitrary encoding to UTF-8

    Here's my dilemma: I recently modified our webapp to use UTF-8 encoding across the board, since data with special characters that users added to the content management backend was being displayed incorrectly in ISO-8859-1. It works great for Strings we get from the database, since it uses UTF-8. The problem now is that there are also files that consist of html chunks that get added to pages when they're rendered by the jsps. Those files aren't always UTF-8 encoded, so characters are displaying incorrectly in those parts of the page.
    The problem is that we don't know what encoding the html chunks are, some are ISO-8859-1, some are Windows-1252, etc. There are hundreds of them, and the users use all kinds of programs to generate the files, Frontpage, Dreamweaver, etc. so there's no common encoding used. I'm trying to modify the code that reads those files so it converts the text to UTF-8 for display, but without knowing what encoding the file is in, how can you do the conversion properly? Here's the code I have currently:
            ByteArrayInputStream contentInput = file.getContent();
            // wrap byte stream in UTF-8 character stream
            BufferedReader br = new BufferedReader(new InputStreamReader(contentInput, "UTF-8"));
            StringBuffer outputBuffer = new StringBuffer("");
            do {
                readString = br.readLine();
                outputBuffer.append(readString);
            while (readString != null);We get a ByteArrayInputStream from the third party API, which I wrap in a UTF-8 encoded BufferedReader. The problem is that, for instance, this character '�', when encoded in the file as ISO-8859-1, get's garbled when converted to UTF-8.
    My question is: Is there a way to convert text to UTF-8 without knowing the encoding of the file? I suspect the answer is no, but I'm really hoping it's yes, since the alternative is re-encoding hundreds to thousands of files in the db, then retraining hundreds of users to always save files as UTF-8. (You can't see my brain spasming at the thought of that, but trust me, it is ;P).

    As an update, in case anyone else runs into this same problem:
    I used the SmartEncodingInputStream from uncle_alice's link, and it works just well enough to solve my problem. The only encoding that it guessed correctly was UTF-8. But it guessed windows-1252 for US-ASCII, windows-1252, and ISO-8859-1. Since 1252 is a superset of ascii and 8859, using 1252 decodes all the characters correctly from those encodings. All the content I tested with was decoded correctly, presumably because it all uses one of those four encodings. The one snag I hit was that the SmartEncodingInputStream doesn't reset the InputStream after it reads it, so I have to do it manually after getting the guessed encoding. Here's the code I used:
            // Get the file content
            ByteArrayInputStream contentInput = file.getContent();
            StringBuffer outputBuffer = new StringBuffer("");
            // wrapper around the input stream that guesses the encoding of the stream
            SmartEncodingInputStream smartIS = null;   
            // use a 8k buffer, and a default encoding of windows-1252
            smartIS = new SmartEncodingInputStream(contentInput, SmartEncodingInputStream.BUFFER_LENGTH_8KB,
                    Charset.forName("windows-1252"));
            String charsetName = smartIS.getEncoding().name();      // get the name of the encoding guessed
            contentInput.reset();       // reset the position to the beginning of the stream
            byte[] contentBuffer = new byte[8192];
            int bytesRead = 0;
            while( (bytesRead = contentInput.read(contentBuffer, 0, 8192)) > 0 ) {
                // encode the output with the encoding guessed by the SmartEncodingInputStream
                outputBuffer.append(new String(contentBuffer, 0, bytesRead, charsetName));
            contentInput.close();I left out the try/catch blocks for readability. I get the ByteArrayInputStream from a library call, and end up with the file contents encoded in UTF-8 in outputBuffer.

  • Convert file format into UTF-8 while generating text file on FTP server

    Hi Expert,
    I have the requirement to generate text file store it in FTP server and file format should be in UTF-8.
    ABAP Development is completed but text file format generate in ANSI which not acceptable by client.For generating text file and store it on FTP server by using standard function module FTP_R3_TO_SERVER ,but in this function module there is no any parameter option like CODEPAGE for file format conversion. Is there any method or any function module to convert file format to UTF-8 and directly transfer or store it on FTP server.
    <<removed_by_moderator>>
    Thanks ,
    Edited by: Vijay Babu Dudla on Jan 28, 2009 12:48 AM

    I have come across the same issue.  Try calling the FTP_COMMAND function module to make it go into ASCII mode before your FTP the file, like this:
    data: result type table of text with header line.
    call function 'FTP_COMMAND'
        exporting
          handle        = hdl
          command       = 'ascii'
        tables
          data          = result
        exceptions
          tcpip_error   = 1
          command_error = 2
          data_error    = 3.
      call function 'FTP_R3_TO_SERVER'
        exporting
          handle         = hdl
          fname          = docid
          character_mode = 'X'
        tables
          text           = gt_your_table .

  • What really happens does it converts ascii to unicode

    hi
    java understands unicode that is 2 byte encoding and office 97 doesn't understand unicode. then how data stored in access 97 (ascii 1 byte encoding) are correctly interpreted by java if i insert '\u0900' a '?' get inserted in to access table
    can someone tell me.

    I would expect that your String data would be converted to bytes using the default encoding on your system, exactly as if you had used "byte[] b = yourString.toBytes()". And since \u0900 is described as "Unassigned" in Unicode, it's most likely to be translated to '?'.

  • Converting ASCII to Binary

    Hello I need some help.
    I need to convert the ASCII data to Binary form. Like if i have the character 'A' and its ASCII is 65 then its binary would be 01000001.
    If there is any function/method available in java to convert ascii to binary, i would be really thanful.

    Hello I need some help.
    I need to convert the ASCII data to Binary form. Like
    if i have the character 'A' and its ASCII is 65 then
    its binary would be 01000001.
    If there is any function/method available in java to
    convert ascii to binary, i would be really thanful.
    byte ascii = 65;
    String binresult = "";
    for(int i=0;i<8;i++) {
      if(ascii%(2^i)=0) binresult += "0";
      else binresult += "1";
    }

  • Convert ASCII File into HTML

    Hi All,
    I have a requirement to convert ASCII files (formatted files when opened through Textpad / Editplus) into HTML when its hyperlink is clicked from my application.
    The present code is that, the TXT file was streamed, html tags have been added and the entire file was re-written as HTML (based on char 12 / 32, as the case may be) and saved as JSP / HTML extension, and placed in a temp folder.
    response.sendRedirect() was used to open this file, which threw OutofMemoryException errors.
    It was also revealed that, if the original ASCII file was 40KB, the converted JSP file would be 160KB (around 4 times)
    The ideal conversion should be - add html tags in the new file and maintain the same formatting as the original ASCII file, & save the file with new extension.
    Thus I need a memory efficient method such that these files are converted on the fly by the application, yet the size kept minimum.
    Please suggest. Thanks in advance
    Regards
    Hari N

    160k is trival on a modern desktop OS. Especially since it is temporary. What heap size is the server using?

  • HELP! Converting ascii to its decimal codes

    Does anyone know how to convert ascii code to its decimal equivalent? Is there a simple function that can do this?
    Thanks for any help!!

    Yes there is.
    String whatever = "whatever"
    char[] chars = whatever.toCharArray();
    for(int i=0; i<chars.length; i++) {
    System.out.println( (int) chars[i] );
    And since its friday I wont flame you for not reading
    a simple tutorial, though its hard not to
    ehmm, the square brackets around the chars[i] are replaced by
    non-squares, or not visible, but they ARE square brackets

  • How to convert ASCII to an integer number??

    Here I am trying to send the number 1000000 from microcontroller through UART and I am recieving the ASCII in labview. But i would like to get exact 1000000 in labview too. So i am trying to convert ASCII to integer but i am unable to do that.
    Solved!
    Go to Solution.

    danil33 wrote:
    Hello mallik,
                       Please don't feel bad.Smercurio and all other experts are trying to make us to do things by our own.THis will make us experts in labview.Thats why he told you to go through the tutorials.I have heard such type of advice(sometimes they scold us) so many times.Still Iam hearingIt is our fault that we won't go through the tutorials properly.Don't get annoyed.
    Besides, the question is quite unclear formulated and makes me almost assume, that the OP hasn't even bothered to look for a solution himself. Since the OP receives a string it would be logical to look in the String palette for some function to do what he wants. And inside that palette there is magically a String/Number Conversion palette, which sounds almost like it could contain at least one function that could do the right thing. (In fact it contains 3 that could work, but I'm sure the OP can find the most logical one for his number easlily).
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How to convert ASCII to CHAR?

    Hi, experts.
    Now I want to convert ASCII to CHAR, can you give me some methods? And I also want to know what's my ABAP Version.
    Thanks in advance!

    *After look so bad code that no work i did my own code, a gift for all you:*
    FORM CHARACTER_ASCII   using    p_letra
                                                 changing p_nro   type i.
    field-symbols: <n> type x.
    assign p_letra to <n> casting.
    move <n> to p_nro.
    ENDFORM.
    FORM ASCII_CHARACTER using    p_nro type i
                                               changing p_letra.
    DATA: c    TYPE c,
          x(4) TYPE x.
    FIELD-SYMBOLS: <fc>  TYPE c.
    x = p_nro.
    ASSIGN x to <fc> CASTING TYPE c.
    MOVE <fc>+1(1) to p_letra.
    ENDFORM.

  • How to convert ascii to character

    how to convert ascii to character is there any function module or any code.plz help me in finding this.

    Hi,
    please go through this
    If I give input as 65 (ascill value) I want display 'A'.
    Below logic is for convert from character to ascii value.
    report Ascii_convert.
    *Going from A to 65
    data : c value 'A'.
    field-symbols : <n> type x.
    data : rn type i.
    assign c to <n> casting.
    move <n> to rn.
    write rn.
    *Going from 66 to B
    data : i type i value 66.
    data : x type x.
    field-symbols : <fc> type c.
    move i to x.
    assign x to <fc> casting type c.
    move <fc> to c.
    write c.
    i hope this will help you ,
    Raja T

  • Convert ascii to hexadecimal

    They forgive my weak knowledge of labview. It needed that they helped me, to convert AsciiI into hexadecimal. I give the following example:    I have a string #01SVT<BL>+098,037 (ASCII) = 2C9 (hexadecimal). how it is that I can get this for labview?    Debtor, and I ask for excuse for my English.

    Hi Luigi,
    why is 2C9 (hexadecimal) = #01SVT<BL>+098,037 (ASCII)?? But anyway, if you want to split your String to extract some parts of the String, there is a function called "split string"
    . And from that splitted part you can make a conversion to a hexadecimal string by converting it into an integer and converting back to a hexa- string. All that functions you can find in the "string"-palette.
    Another hint (and one of the reasons i'm so inspired by LabView) is: If you want to test the behaviour of a function or VI, simply open a new blank VI, drop the function to examine and create appropriate controls and indicators of the interesting In- and Outputs by the context menu of the connectors. Then you can type in some testdata and run the VI to see, what the function does. This is a very fast way to create a testing environment for the function.
    Hope this helps,
    Dave
    Greets, Dave

  • To Convert ASCII Data to PDF file

    Hello,
    Does any one knows how to convert ASCII data into PDF document using Java. I know there are some 3 party tools available which does this, but i don't want to use any 3 party tools.
    Can help on this matter, doing it using java programming will be appreciated

    if you don't want to use 3rd party tools, then you will need to go read either the source of an app that does it, and port/copy it.
    Or go read the the specs.

  • Converting ascii to iCal?

    I currently use Solaris CDE with Calendar details kept
    in ascii format. If I am going to use iPlanet's latest
    version of Calendar I need a way of importing all of ascii files for users into iCal. Otherwise I'm left resubmitting all details for the year.

    Hello I need some help.
    I need to convert the ASCII data to Binary form. Like
    if i have the character 'A' and its ASCII is 65 then
    its binary would be 01000001.
    If there is any function/method available in java to
    convert ascii to binary, i would be really thanful.
    byte ascii = 65;
    String binresult = "";
    for(int i=0;i<8;i++) {
      if(ascii%(2^i)=0) binresult += "0";
      else binresult += "1";
    }

  • How can I convert ASCII characters to ISO8859?

    Hi All,
    I have written a little application that renames a TV episode by scraping a TV listing site for the episode name. It is written in SWT and works great apart from on small problem. When getting the html back from the site, it sometimes contains special ASCII characters that are not in the ISO8859 (Windows filesystem) character set.
    For example, this is the line that I have to parse:
    <td style='padding-left: 6px;' class='b2'><a href='/Prison_Break/episodes/569183/03x01'>Orientaci��n</a></td>When viewing it in a browser, it is:
    <td style="padding-left: 6px;" class="b2"><a href="/Prison_Break/episodes/569183/03x01">Orientaci�n</a></td>Notice that the o in the title has an accent on it. While researching this problem I stumbled across 'HTML Entities to ISO 8859-1 Converter' at http://www.inweb.de/chetan/English/Resources/Java/HTML%202%20ISO.html. This open source project takes in an html entity like & and returns '&'.
    So that is not quite what I want, as my BufferedReader is converting the html entity into the ASCII representation already. I need a way of detecting a non ISO8859 character within an ASCII string, and hopefully replacing its natural 'equivalent' (would be o in this case).
    Does anyone know how I could do it without having to check for every special char and replacing (not really an option unless someone has done it before!!)
    If not that then, perhaps another way to attack the problem?
    Any help greatly appreciated ;)
    Dave

    Hi,
    NZ_Dave wrote:
    For example, this is the line that I have to parse:
    <td style='padding-left: 6px;' class='b2'><a href='/Prison_Break/episodes/569183/03x01'>Orientaci��n</a></td>
    This is coded in UTF-8. If you convert the bytes to a String using the UTF-8 encoding, then you will have the correct characters "Orientaci�n" in the string.
    Check your parser where it converts the bytes (coming from e.g. an InputStream) to characters. Use UTF-8 as the charset when doing that conversion.

Maybe you are looking for