ANSEL Charset

As part of a GEDCOM package I need to decode ANSEL encoded files so I have written an ANSEL Charset. This seems to work though, being the first Decoder I have written, I am not sure of the logic required for the decodeLoop() method of the CharsetDecoder.
I would appreciate any comments on the logic of the decodeLoop() method.
import java.nio.charset.*;
import java.nio.*;
* A Charset to decode the GEDCOM character encoding ANSEL.
* <br>
* Mainly taken from http://lcweb2.loc.gov/cocoon/codetables/45.html
* @author sabre
public class AnselCharset extends Charset
    private static final char[] ANSEL_CHARS = new char[256];
    static
        // The ASCII root
        for (int index = 0; index < 128; index++)
            ANSEL_CHARS[index] = (char)index;
        // Invalid characters traslation
        java.util.Arrays.fill(ANSEL_CHARS, 128, ANSEL_CHARS.length, '?');
        // The ANSEL characters
        ANSEL_CHARS[0x88]='\u0098';//NON-SORT BEGIN / START OF STRING
        ANSEL_CHARS[0x89]='\u009C';//NON-SORT END / STRING TERMINATOR
        ANSEL_CHARS[0x8D]='\u009C';//JOINER / ZERO WIDTH JOINER
        ANSEL_CHARS[0x8E]='\u009C';//NON-JOINER / ZERO WIDTH NON-JOINER
        ANSEL_CHARS[0xA1]='\u0141';//UPPERCASE POLISH L / LATIN CAPITAL LETTER L WITH STROKE
        ANSEL_CHARS[0xA2]='\u00D8';//UPPERCASE SCANDINAVIAN O / LATIN CAPITAL LETTER O WITH STROKE
        ANSEL_CHARS[0xA3]='\u0110';//UPPERCASE D WITH CROSSBAR / LATIN CAPITAL LETTER D WITH STROKE
        ANSEL_CHARS[0xA4]='\u00DE';//UPPERCASE ICELANDIC THORN / LATIN CAPITAL LETTER THORN (Icelandic)
        ANSEL_CHARS[0xA5]='\u00C6';//UPPERCASE DIGRAPH AE / LATIN CAPITAL LIGATURE AE
        ANSEL_CHARS[0xA6]='\u0152';//UPPERCASE DIGRAPH OE / LATIN CAPITAL LIGATURE OE
        ANSEL_CHARS[0xA7]='\u02B9';//SOFT SIGN, PRIME / MODIFIER LETTER PRIME
        ANSEL_CHARS[0xA8]='\u00B7';//MIDDLE DOT
        ANSEL_CHARS[0xA9]='\u266D';//MUSIC FLAT SIGN
        ANSEL_CHARS[0xAA]='\u00AE';//PATENT MARK / REGISTERED SIGN
        ANSEL_CHARS[0xAB]='\u00B1';//PLUS OR MINUS / PLUS-MINUS SIGN
        ANSEL_CHARS[0xAC]='\u01A0';//UPPERCASE O-HOOK / LATIN CAPITAL LETTER O WITH HORN
        ANSEL_CHARS[0xAD]='\u01AF';//UPPERCASE U-HOOK / LATIN CAPITAL LETTER U WITH HORN
        ANSEL_CHARS[0xAE]='\u02BC';//ALIF / MODIFIER LETTER APOSTROPHE
        ANSEL_CHARS[0xB0]='\u02BB';//AYN / MODIFIER LETTER TURNED COMMA
        ANSEL_CHARS[0xB1]='\u0142';//LOWERCASE POLISH L / LATIN SMALL LETTER L WITH STROKE
        ANSEL_CHARS[0xB2]='\u00F8';//LOWERCASE SCANDINAVIAN O / LATIN SMALL LETTER O WITH STROKE
        ANSEL_CHARS[0xB3]='\u0111';//LOWERCASE D WITH CROSSBAR / LATIN SMALL LETTER D WITH STROKE
        ANSEL_CHARS[0xB4]='\u00FE';//LOWERCASE ICELANDIC THORN / LATIN SMALL LETTER THORN (Icelandic)
        ANSEL_CHARS[0xB5]='\u00E6';//LOWERCASE DIGRAPH AE / LATIN SMALL LIGATURE AE
        ANSEL_CHARS[0xB6]='\u0153';//LOWERCASE DIGRAPH OE / LATIN SMALL LIGATURE OE
        ANSEL_CHARS[0xB7]='\u02BA';//HARD SIGN, DOUBLE PRIME / MODIFIER LETTER DOUBLE PRIME
        ANSEL_CHARS[0xB8]='\u0131';//LOWERCASE TURKISH I / LATIN SMALL LETTER DOTLESS I
        ANSEL_CHARS[0xB9]='\u00A3';//BRITISH POUND / POUND SIGN
        ANSEL_CHARS[0xBA]='\u00F0';//LOWERCASE ETH / LATIN SMALL LETTER ETH (Icelandic)
        ANSEL_CHARS[0xBC]='\u01A1';//LOWERCASE O-HOOK / LATIN SMALL LETTER O WITH HORN
        ANSEL_CHARS[0xBD]='\u01B0';//LOWERCASE U-HOOK / LATIN SMALL LETTER U WITH HORN
        ANSEL_CHARS[0xC0]='\u00B0';//DEGREE SIGN
        ANSEL_CHARS[0xC1]='\u2113';//SCRIPT SMALL L
        ANSEL_CHARS[0xC2]='\u2117';//SOUND RECORDING COPYRIGHT
        ANSEL_CHARS[0xC3]='\u00A9';//COPYRIGHT SIGN
        ANSEL_CHARS[0xC4]='\u266F';//MUSIC SHARP SIGN
        ANSEL_CHARS[0xC5]='\u00BF';//INVERTED QUESTION MARK
        ANSEL_CHARS[0xC6]='\u00A1';//INVERTED EXCLAMATION MARK
        ANSEL_CHARS[0xC7]='\u00DF';//ESZETT SYMBOL
        ANSEL_CHARS[0xC8]='\u20AC';//EURO SIGN
        ANSEL_CHARS[0xE0]='\u0309';//PSEUDO QUESTION MARK / COMBINING HOOK ABOVE
        ANSEL_CHARS[0xE1]='\u0300';//GRAVE / COMBINING GRAVE ACCENT (Varia)
        ANSEL_CHARS[0xE2]='\u0301';//ACUTE / COMBINING ACUTE ACCENT (Oxia)
        ANSEL_CHARS[0xE3]='\u0302';//CIRCUMFLEX / COMBINING CIRCUMFLEX ACCENT
        ANSEL_CHARS[0xE4]='\u0303';//TILDE / COMBINING TILDE
        ANSEL_CHARS[0xE5]='\u0304';//MACRON / COMBINING MACRON
        ANSEL_CHARS[0xE6]='\u0306';//BREVE / COMBINING BREVE (Vrachy)
        ANSEL_CHARS[0xE7]='\u0307';//SUPERIOR DOT / COMBINING DOT ABOVE
        ANSEL_CHARS[0xE8]='\u0308';//UMLAUT, DIAERESIS / COMBINING DIAERESIS (Dialytika)
        ANSEL_CHARS[0xE9]='\u030C';//HACEK / COMBINING CARON
        ANSEL_CHARS[0xEA]='\u030A';//CIRCLE ABOVE, ANGSTROM / COMBINING RING ABOVE
        ANSEL_CHARS[0xEB]='\u0361';//LIGATURE, FIRST HALF / COMBINING DOUBLE INVERTED BREVE     FE20     EFB8A0
        ANSEL_CHARS[0xEC]='\uFE21';//LIGATURE, SECOND HALF / COMBINING LIGATURE RIGHT HALF     FE21     EFB8A1
        ANSEL_CHARS[0xED]='\u0315';//HIGH COMMA, OFF CENTER / COMBINING COMMA ABOVE RIGHT
        ANSEL_CHARS[0xEE]='\u030B';//DOUBLE ACUTE / COMBINING DOUBLE ACUTE ACCENT
        ANSEL_CHARS[0xEF]='\u0310';//CANDRABINDU / COMBINING CANDRABINDU
        ANSEL_CHARS[0xF0]='\u0327';//CEDILLA / COMBINING CEDILLA
        ANSEL_CHARS[0xF1]='\u0328';//RIGHT HOOK, OGONEK / COMBINING OGONEK
        ANSEL_CHARS[0xF2]='\u0323';//DOT BELOW / COMBINING DOT BELOW
        ANSEL_CHARS[0xF3]='\u0324';//DOUBLE DOT BELOW / COMBINING DIAERESIS BELOW
        ANSEL_CHARS[0xF4]='\u0325';//CIRCLE BELOW / COMBINING RING BELOW
        ANSEL_CHARS[0xF5]='\u0333';//DOUBLE UNDERSCORE / COMBINING DOUBLE LOW LINE
        ANSEL_CHARS[0xF6]='\u0332';//UNDERSCORE / COMBINING LOW LINE
        ANSEL_CHARS[0xF7]='\u0326';//LEFT HOOK (COMMA BELOW) / COMBINING COMMA BELOW
        ANSEL_CHARS[0xF8]='\u031C';//RIGHT CEDILLA / COMBINING LEFT HALF RING BELOW
        ANSEL_CHARS[0xF9]='\u032E';//UPADHMANIYA / COMBINING BREVE BELOW
        ANSEL_CHARS[0xFA]='\uFE22';//DOUBLE TILDE, FIRST HALF / COMBINING DOUBLE TILDE     FE22     EFB8A2
        ANSEL_CHARS[0xFB]='\uFE23';//DOUBLE TILDE, SECOND HALF / COMBINING DOUBLE TILDE RIGHT HALF     FE23     EFB8A3
        ANSEL_CHARS[0xFE]='\u0313';//HIGH COMMA, CENTERED / COMBINING COMMA ABOVE (Psili)
    public AnselCharset()
        super("ANSEL", null);
    public CharsetDecoder newDecoder()
        return new Decoder(this);
    public CharsetEncoder newEncoder()
        throw new UnsupportedOperationException("ANSEL Encoding not supported");
    public boolean contains(Charset cs)
        return displayName().equals(cs.displayName());
    public boolean canEncode()
        return false;
    private static class Decoder extends CharsetDecoder
        private Decoder(Charset cs)
            super(cs, 1.0f, 1.0f);
        protected CoderResult decodeLoop(ByteBuffer in, CharBuffer out)
            while (in.hasRemaining())
                if (out.hasRemaining())
                    int b = in.get() & 0xff;
                    out.put(ANSEL_CHARS);
else
return CoderResult.OVERFLOW;
return CoderResult.UNDERFLOW;

> Thanks for this, I have been thinking of buying a
book on NIO so I might order the "Java NIO" book.
sabre, if you want to look before buying, you can view some pages (or the table of contents) through Google-books:
http://books.google.com/books?vid=ISBN0596002882&id=BSz14O3uQwsC&pg=PP1&lpg=PP1&dq=O'Reilly+Java+NIO&sig=8uC-pkytAU6y7RXDBKS_O6EwRAk

Similar Messages

  • How to change the default database charset to ISO8859-1?

    Hi all,
    I have created a table with a nvarchar field to store string, may i now how to change the default NLS charset to ISO88591 charset?
    Thanks in advance.
    chin.

    Thank you!
    I will try later!
    But,who can tell me more detail !
    thx

  • Two-way SSL: Private key is incorrectly read if the charset is set to UTF8

    Looks like PEMInputStream and other related classes assumes the application charset
    "iso81", but if the charset is something else, then "java.security.KeyManagementException"
    is thrown.
    We have everything setup and two-way ssl works when the encoding is not set. but
    brakes if the encoding is UTF8.
    WLS 7.0
    OS - HP-UX
    Is there any other workaround (not setting UTF8 is not a solution, ours is a WW
    app).
    Thanks

    I would suggest posting this to the security newsgroup.
    -- Rob
    Govinda Raj wrote:
    Looks like PEMInputStream and other related classes assumes the application charset
    "iso81", but if the charset is something else, then "java.security.KeyManagementException"
    is thrown.
    We have everything setup and two-way ssl works when the encoding is not set. but
    brakes if the encoding is UTF8.
    WLS 7.0
    OS - HP-UX
    Is there any other workaround (not setting UTF8 is not a solution, ours is a WW
    app).
    Thanks

  • Problem with charsets for foreign languages

    hi
    i have a problem with a webapplication
    in my webapplication i have some code that gets data from a webpage of another webapplication. This other web application can use many foreign languages
    the problem is that those foreign languages contain some special characters, and those special chars aren't displayed the right way
    this is the code to get the data from the other webapp
    private static StringBuffer getContent(String sUrl) throws MalformedURLException, IOException  {
            StringBuffer content = new StringBuffer();
            URL url = new URL(sUrl);
            HttpURLConnection httpURLConn = (HttpURLConnection) url.openConnection();
            httpURLConn.setRequestProperty("charset", "utf-8");
            BufferedReader buffReader = new BufferedReader(new InputStreamReader(httpURLConn.getInputStream()));
            String inputLine;
            while ((inputLine = buffReader.readLine()) != null) {
                content.append("\n" + inputLine);
            return content;
        }as you see , i tried to set the encoding to UTF-8 but that did not solve the problem

    an example of those special chars
    fran�aisis displayed as
    code]
    fran��ais

  • PDF Embed is not working with BRAZILIAN Charset

    Hello,
    a strange thing is happening with my reports server 9i.
    I have Oracle 9ias R2 with 9.0.2.3 patchset and Forms and Reports 9.0.2.3 patchset installed on Red Hat Linux.
    I have a report that uses a post script barcode font, and i'm using the PDF Embed feature to incorporate this font in the reports.
    The problem is that everything works fine when the NLS_LANG is defined to AMERICAN_AMERICA.WE8ISO8859P1, the barcodes are showing correctly. But, when i set the NLS_LANG="BRAZILIAN PORTUGUESE_BRAZIL.WE8ISO8859P1" only a small initial part of the barcodes is showed on the screen.
    I have to use this charset because my database is using it. With the AMERICAN charset the dates and other kind of stuff are showed in english.
    Resuming, i need to use the PDF Embed font with the charset defined to BRAZILIAN PORTUGUESE_BRAZIL.WE8ISO8859P1.
    Is this some kind of bug??
    How can i solve this issue??
    Thank you all.
    Marcus Santos
    ([email protected])

    Marcos,
    Experimente fazer a convers�o do valor para caracteres em ASCII conforme tabela do Bar Code 2/5.
    Voce associa a coluna de formula ao fonte bar25 i.. e dentro da fun��o vc converte cada par de caracter ao valor correspondente..
    Espero que te sirva...
    Um abra�o
    Ary

  • Is there a way to force the charset to utf-8 with the IIS plug-in?

    We're using AJAX. The initial request for the HTML has charset=utf-8 set on the HTTP header as seen in this Live HTTP Headers capture:
    http://plper.mysite.com/mysupport/index.jsf
    GET /mysupport/index.jsf HTTP/1.1
    Host: plper.mysite.com
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14
    Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 300
    Connection: keep-alive
    Cookie: mysiteSiteUrl=http://www.mysite.com; Amysession=aHR0cDovL3BscGVyLmVtYy5jb206ODAv; JSESSIONID=FN3WLTNJFJCfYhHHVrwKvLHF2gGdnnTb11DrCyZqR9YbGhcG28lK!-1728721171; mysession=AAAAAgABAFBy5LRMDmjSRCN%2FByvfquVwFeKCpmES4x9lReRava35fxKfwcbJimb3YyPhEd0vBq7ZxgJVecL475TFZwQuSphLOwRWAQw2t7PEW%2BrxsfxgnQ%3D%3D
    HTTP/1.x 200 OK
    Date: Tue, 10 Jun 2008 18:53:01 GMT
    Server: Microsoft-IIS/6.0
    Cache-Control: no-store,no-cache,must-revalidate, no-cache="set-cookie"
    Pragma: No-cache
    Transfer-Encoding: chunked
    Content-Type: text/html;charset=UTF-8
    Expires: Thu, 01 Jan 1970 00:00:00 GMT
    Set-Cookie: JSESSIONID=09VTLTNWT07LlqnK22jTWwM8y5L9v1rmPf9CTW5TnGGKBvWvjJpP!-1728721171; path=/
    Content-Language: en-US
    X-Powered-By: Servlet/2.5 JSP/2.1
    Subsequent requests do not:
    http://plper.mysite.com/mysupport/index.jsf
    POST /mysupport/index.jsf HTTP/1.1
    Host: plper.mysite.com
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14
    Accept: application/x-backbase+xml,application/xhtml+xml,application/xml,text/xml,application/x-www-form-urlencoded,*/*;q=0.5
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 300
    Connection: keep-alive
    Content-Type: application/x-www-form-urlencoded
    Referer: http://plper.mysite.com/mysupport/index.jsf
    Content-Length: 122
    Cookie: mysiteSiteUrl=http://www.mysite.com; Amysession=aHR0cDovL3BscGVyLmVtYy5jb206ODAv; JSESSIONID=09VTLTNWT07LlqnK22jTWwM8y5L9v1rmPf9CTW5TnGGKBvWvjJpP!-1728721171; mysession=AAAAAgABAFBRtE5lAyr85YM0aIap%2Bekf1Qu8FoA6BNh4JVl1JgvDNDQgYrQm5m9W%2FQa4HLK767CtXV5c%2FhtXchbug9%2BE1zoCmqSBqqYmqXE9VG1lXi%2F%2Brg%3D%3D
    Pragma: no-cache
    Cache-Control: no-cache
    BackbaseClientDelta=%5Bevt%3DsrQuery%3AsiteList%7Cevent%7Csubmit%5D%5Bvalue%3DsrQuery%3AsiteList%7Cmultivalue%7C3971957%5D
    HTTP/1.x 200 OK
    Date: Tue, 10 Jun 2008 18:58:17 GMT
    Server: Microsoft-IIS/6.0
    Content-Length: 1720
    Content-Type: text/xml
    X-Powered-By: Servlet/2.5 JSP/2.1
    Is there a way to force requests going through the proxy plug-in to get a charset=utf-8 set in the HTTP header for all requests?
    Thanks!
    Edited by f2racer at 06/10/2008 12:01 PM

    If for some reason you have failed to maintain a backup copy of your computer ( not good), then transfer purchases form your ipod.
    Without syncing, click File>Transfer Purchases

  • Possible to change the charset of a Web Dynpro Application ?

    Hello All,
      Does anyone knows if this is possible ? To be able to change the charset of a Web Dynpro application or even changing it dynamically ? Thank you.
    from
    Kwok Wei

    Hello Anilkumar,
      Sorry for not elaborating further again (This is getting to be a habit ;p).
      I have the document on "international of wed dynpro application" but it appears to be more on customising the label fields to reflect the corresponding text in different languages. This is indeed a very cool idea. However, the reason why I am asking if it is possible to change the charset is because (do correct me if I am wrong)I need to display japanese and english characters and to do that I need to change the charset so that Web Dynpro can have them displayed properly. Is this assumption correct ?
      I have actually log a CSN ticket on this query as well and this is the reply "...... My understanding is that with Web Dynpro Java being based on Unicode, we don't need to charset settings. One should be able to display both Japanese and other characters in parallel, automatically, without problem."
      Your comments please. Thank you.
    from
    kw

  • How to find charset of a string??

    i pass an input thru a utf-8 encoded html form to a jsp. when i read it using bufferedreader and when i do request.getencoding( input text) it always shows me ISO8859_1, whether the data is english or japanese or any other language. how do i get the charset (SJIS or EUCJIS etc) of a text entered by the user in the html form???

    thanks conner
    i have one big problem here(hope you'll help)
    my application takes in data from the user (multilingual data) and then submits it to a jsp which in turn inserts the data into a oracle db(UTF-8). the html form is UTF-8 and the content type of the JSP is UTF-8. the same jsp then retreives the data fromthe db and shows it onto a different htmlpage. the whole process is working fine i.e if i enter japanese text the jsp after retreiving from the db shows me the same data back on the browser. but when i check the contents of the db using SQL query it shows me SJIS encoded data. i think the data from the jsp to the db itself is getting changed into SJIS and to back this up i exported the data from the db into a text file there it showed me the equivalent inserts statements of the jsp but with SJIS data and not the data i entered.(hope you're getting my point here) what could be the problem here? one way i thought i could solve the problem was to use the SetCharacterEncoding(before accepting any data from the HTMlpage) method but this is available only in jsdk2.3 version . am i right to think that using this function would solve my problem? is there an alternative to this function ?
    thanks

  • CHARSET for Korean language to open Korean .wft files in workflow.

    Hi,
    I want to open Korean .wft files in oracle workflow builder.
    For that, I had given 'KOREAN_KOREA.KO16KSC5601' (and also 'KO16KSCCS' as charset) as the NLS_LANG value in the window registry but I am getting following error once I logged in to database using workflow builder:
    1300: Could not load.
    1114: Could not load from database.
    1101: Could not load item types from database. FILTER=%
    333: Could not set item type properties for 'FPAPJP'.
    332: 'SET' validation failed for item type 'FPAPJP'.
    306: Invalid display name 'Project Portfolio Analysis '.
    203: Value contains leading or trailing spaces.
    When I tried with 'KO16DBCS' charset, I am getting following error:
    1700: Could not connect with username/password 'apps/apps@cxlv1' ('ORA-01017: ‰•¥“‰„@¤¢…™•”…a—¢¢¦–™„^@“–‡–•@„…•‰…„
    though I am using the same username/password and tnsname that I am using to connect english and japanese .wft files.
    Please share with me the correct charset for korean language to be able to work with workflow builder.
    Thanks,
    Sumit
    Edited by: SumitBansal on Jan 7, 2009 1:30 PM
    Edited by: SumitBansal on Jan 7, 2009 1:32 PM

    Thanks for your reply...
    It didn't work..When I am giving AMERICAN_AMERICA.KO16KSC5601 as value for NLS_LANG, workflow builder is fetching wft only in American English !..
    Any other clue!!

  • Problem viewing/updating MySQL-database with utf-8 charset

    System specs:
    Tomcat 5.5.4
    JDK1.5.0
    MySQL 4.1
    Connector/J 3.0.16
    JSTL 1.1
    I am trying to build a guestbook web-app, and want to be able to store swedish characters (available in latin1) and decided to give utf-8 a go since it would support other languages as well. I use a <Resource> in my context-xml to get the connection.
    This simply will not work; when I use the <%@ page contentType="text/html; charset=utf-8"%> declaration, the swedish characters in the raw html-code gets replaced by questionmarks. Select-queries output look ok though, as long as they don't contain the character '�'
    When removing the page-declaration, the queries show only questionmarks where swedish characters should be.
    The same goes for updating my database. Swedish characters get garbled.
    I have tried the following without success:
    *adding &useUnicode=true&characterEncoding=UTF-8 to the Resource-url -- causes my web-app to fail loading.
    *adding a <filter> to the web-apps web.xml as suggested at  http://www.javaworld.com/javaworld/jw-09-2004/jw-0906-unicode_p.html -- caused another web-app error, resulting in it not being loaded.
    *setting the form attribute accept-charset -- resulted in no improvement.
    Right now I'm half desperate and half fed-up. Is this a common problem with MySQL? Should I use another database? Or perhaps it is the Connector/J Driver that's messing things up.
    I'll appreciate any help I get greatly.

    Hello. Maybe not so interesting after a year to try to ask did you ever get a final solution to that problem in command line perspective. OR does somebody else knows solution to this problem.
    Anyway I have similar problem, I use mysql5 with latin1 charset and I can insert to my database letters ��� normally via mysql command line and they show perfectly. But the problem is my web application.
    I can insert all characters to database and retrieve them normally via web app but if i need to use mysql command line for queries it fails because those special letters appear something like ��. I still need to make queries on mysql command line as admin. I have also tried to change different drivers like
    Class.forName("org.gjt.mm.mysql.Driver"); or
    com.mysql.jdbc.Driver etc connector is 3.0.17
    I have also tried to change to utf-8 and then changed mysql def.enc to same... i have used request.setWHATEVER CHARSET.....i'm out of ideas... help?

  • XML encoding to UTF-8 charset - Oracle 9i

    Hi Masters
    Database Version : 9i
    Can you please help me here.. I am in a process of writing an Inventory Adjustment tool that will generate the XML and encode it to utf-8 charset…
    I have successfully written the code to generate the XML in this format
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <InvAdjustDesc>
    <dc_dest_id>323</dc_dest_id>
    <InvAdjustDtl>
    <item_id>12345678</item_id>
    <adjustment_reason_code>383</adjustment_reason_code>
    <unit_qty>4</unit_qty>
    <from_disposition>ATS</from_disposition>
    <to_disposition/>
    <user_id>e7062159</user_id>
    <create_date>
    <year>2012</year>
    <month>10</month>
    <day>29</day>
    <hour>14</hour>
    <minute>59</minute>
    <second>25</second>
    </create_date>
    <ww_liability_code>353</ww_liability_code>
    <ww_ref_1/>
    <ww_ref_2/>
    <ww_tran_id>25863399875</ww_tran_id>
    <ww_alloc_no/>
    <ww_final_store>353</ww_final_store>
    </InvAdjustDtl>
    </InvAdjustDesc>
    And now as part of the AIT requirement this XML needs to be encoded to utf-8 and look like this
    <?xml version="1.0" encoding="UTF-8"?><RibMessages><ribMessage><family>InvAdjust</family><type>INVADJUSTCRE</type><id>54601557</id><ribmessageID>3</ribmessageID><publishTime>2012-10-29 15:03:12.000 SAST</publishTime><messageData>&lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot; ?&gt;&lt;InvAdjustDesc&gt;&lt;dc_dest_id&gt;323&lt;/dc_dest_id&gt;&lt;InvAdjustDtl&gt;&lt;item_id&gt;12345678&lt;/item_id&gt;&lt;adjustment_reason_code&gt;383&lt;/adjustment_reason_code&gt;&lt;unit_qty&gt;4&lt;/unit_qty&gt;&lt;from_disposition&gt;ATS&lt;/from_disposition&gt;&lt;to_disposition/&gt;&lt;user_id&gt;e7062159&lt;/user_id&gt;&lt;create_date&gt;&lt;year&gt;2012&lt;/year&gt;&lt;month&gt;10&lt;/month&gt;&lt;day&gt;29&lt;/day&gt;&lt;hour&gt;14&lt;/hour&gt;&lt;minute&gt;59&lt;/minute&gt;&lt;second&gt;25&lt;/second&gt;&lt;/create_date&gt;&lt;ww_liability_code&gt;353&lt;/ww_liability_code&gt;&lt;ww_ref_1/&gt;&lt;ww_ref_2/&gt;&lt;ww_tran_id&gt;25863399875&lt;/ww_tran_id&gt;&lt;ww_alloc_no/&gt;&lt;ww_final_store&gt;353&lt;/ww_final_store&gt;&lt;/InvAdjustDtl&gt;&lt;/InvAdjustDesc&gt;</messageData><customFlag>F</customFlag></ribMessage></RibMessages>
    I am not quite familiar with xml encoding do you have any suggestion on how i can accomplish this?
    Thanks

    Hi Odie
    I found a way of writing the encoded xml thanks for your help my man, much appreciated...
    But now can you help me here this xml I am generating needs to be like the one at the bottom...
    Here is my SQL I am using....
    SELECT XMLELEMENT
    ("InvAdjustDesc"
    ,XMLFOREST
    (inv.dc_dest_id AS "dc_dest_id"
    ,XMLFOREST
    (NVL(inv.item_id, ' ') AS "item_id"
    ,NVL(inv.adjustment_reason_code, ' ') AS "adjustment_reason_code"
    ,NVL(inv.unit_qty, 0) AS "unit_qty"
    ,NVL(inv.from_disposition, ' ') AS "from_disposition"
    ,NVL(inv.to_disposition, ' ') AS "to_disposition"
    ,NVL(inv.user_id, ' ') AS "user_id"
    ,XMLFOREST(TO_CHAR(SYSDATE, 'yyyy') AS "year"
    ,TO_CHAR(SYSDATE, 'mm') AS "month"
    ,TO_CHAR(SYSDATE, 'dd') AS "day"
    ,TO_CHAR(SYSDATE, 'hh') AS "hour"
    ,TO_CHAR(SYSDATE, 'mi') AS "minute"
    ,TO_CHAR(SYSDATE, 'ss') AS "second"
    ) AS create_date
    ,NVL(inv.ww_liability_code, ' ') AS "ww_liability_code"
    ,NVL(inv.ww_ref_1, ' ') AS "ww_ref_1"
    ,NVL(inv.ww_ref_2, ' ') AS "ww_ref_2"
    ,NVL(inv.ww_tran_id, ' ') AS "ww_tran_id"
    ,NVL(inv.ww_alloc_no, ' ') AS "ww_alloc_no"
    ,NVL(inv.ww_final_store, ' ') AS "ww_final_store"
    ) AS InvAdjustDtl)) AS InvAdjustDesc
    FROM invadjust inv
    WHERE inv.dc_dest_id = 342
    and rownum <= 3;
    I need to have a leading <InvAdjustDesc> with a node <dc_dest_id> with repeating <InvAdjustDtl>
    I did try to put XMLAGG to group all of my <InvAdjustDtl> nodes but the output I get is two entries of <InvAdjustDtl> as follows
    <InvAdjustDesc>
    <dc_dest_id>323</dc_dest_id>
    <INVADJUSTDTL>
    <InvAdjustDtl>
    <item_id>20144791</item_id>
    <adjustment_reason_code>6</adjustment_reason_code>
    <unit_qty>-4</unit_qty>
    <from_disposition>ATS</from_disposition>
    <to_disposition />
    <user_id>r7052891</user_id>
    <CREATE_DATE>
    <year>2012</year>
    <month>10</month>
    <day>31</day>
    <hour>10</hour>
    <minute>15</minute>
    <second>44</second>
    </CREATE_DATE>
    <ww_liability_code>342</ww_liability_code>
    <ww_ref_1 />
    <ww_ref_2 />
    <ww_tran_id>342021751178</ww_tran_id>
    <ww_alloc_no />
    <ww_final_store>342</ww_final_store>
    </InvAdjustDtl>
    <InvAdjustDtl>
    <item_id>6009173222220</item_id>
    <adjustment_reason_code>6</adjustment_reason_code>
    <unit_qty>-1</unit_qty>
    <from_disposition>ATS</from_disposition>
    <to_disposition />
    <user_id>r7052891</user_id>
    <CREATE_DATE>
    <year>2012</year>
    <month>10</month>
    <day>31</day>
    <hour>10</hour>
    <minute>15</minute>
    <second>44</second>
    </CREATE_DATE>
    <ww_liability_code>342</ww_liability_code>
    <ww_ref_1 />
    <ww_ref_2 />
    <ww_tran_id>342021751179</ww_tran_id>
    <ww_alloc_no />
    <ww_final_store>342</ww_final_store>
    </InvAdjustDtl>
    <InvAdjustDtl>
    <item_id>2034180000008</item_id>
    <adjustment_reason_code>6</adjustment_reason_code>
    <unit_qty>-1</unit_qty>
    <from_disposition>ATS</from_disposition>
    <to_disposition />
    <user_id>r7052891</user_id>
    <CREATE_DATE>
    <year>2012</year>
    <month>10</month>
    <day>31</day>
    <hour>10</hour>
    <minute>15</minute>
    <second>44</second>
    </CREATE_DATE>
    <ww_liability_code>342</ww_liability_code>
    <ww_ref_1 />
    <ww_ref_2 />
    <ww_tran_id>342021751180</ww_tran_id>
    <ww_alloc_no />
    <ww_final_store>342</ww_final_store>
    </InvAdjustDtl>
    </INVADJUSTDTL>
    </InvAdjustDesc>cond>11</second>
    </CREATE_DATE>
    <ww_liability_code>342</ww_liability_code>
    <ww_ref_1 />
    <ww_ref_2 />
    <ww_tran_id>342021751180</ww_tran_id>
    <ww_alloc_no />
    <ww_final_store>342</ww_final_store>
    </INVADJUSTDTL>
    </InvAdjustDesc>cond>11</second>
    </CREATE_DATE>
    <ww_liability_code>342</ww_liability_code>
    <ww_ref_1 />
    <ww_ref_2 />
    <ww_tran_id>342021751180</ww_tran_id>
    <ww_alloc_no />
    <ww_final_store>342</ww_final_store>
    </INVADJUSTDTL>
    </InvAdjustDesc>
    --------------------------------------Desired Output___________________
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <InvAdjustDesc>
         <dc_dest_id>852</dc_dest_id>
         <InvAdjustDtl>
              <item_id>12345</item_id>
              <adjustment_reason_code>989</adjustment_reason_code>
              <unit_qty>4</unit_qty>
              <from_disposition>ats</from_disposition>
              <to_disposition>tst</to_disposition>
              <user_id>w759862</user_id>
              <create_date>
                   <year>2012</year>
                   <month>10</month>
                   <day>31</day>
                   <hour>09</hour>
                   <minute>14</minute>
                   <second>23</second>
              </create_date>
              <ww_liability_code>852</ww_liability_code>
              <ww_ref_1/>
              <ww_ref_2/>
              <ww_tran_id>12358965</ww_tran_id>
              <ww_alloc_no/>
              <ww_final_store>323</ww_final_store>
         </InvAdjustDtl>
         <InvAdjustDtl>
              <item_id>78952675</item_id>
              <adjustment_reason_code>987</adjustment_reason_code>
              <unit_qty>5</unit_qty>
              <from_disposition>ats</from_disposition>
              <to_disposition>asr</to_disposition>
              <user_id>w7889526</user_id>
              <create_date>
                   <year>2012</year>
                   <month>10</month>
                   <day>31</day>
                   <hour>09</hour>
                   <minute>15</minute>
                   <second>02</second>
              </create_date>
              <ww_liability_code>456</ww_liability_code>
              <ww_ref_1/>
              <ww_ref_2/>
              <ww_tran_id>482665226</ww_tran_id>
              <ww_alloc_no/>
              <ww_final_store>456</ww_final_store>
         </InvAdjustDtl>
    </InvAdjustDesc>

  • Sharepoint error - Search Issue - The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (application/soap+msbin1).

    i see this error everywhere - In ULS logs, on site. On the site > Site settings > search keywords; I see this - 
    The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (application/soap+msbin1). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>IIS 7.0 Detailed Error - 500.19 - Internal Server Error</title> <style type="text/css"> <!-- body{margin:0;font-size:.7em;font-family:Verdana,Arial,Helvetica,sans-serif;background:#CBE1EF;} code{margin:0;color:#006600;font-size:1.1em;font-weight:bold;} .config_source code{font-size:.8em;color:#000000;} pre{margin:0;font-size:1.4em;word-wrap:break-word;} ul,ol{margin:10px 0 10px 40px;} ul.first,ol.first{margin-top:5px;} fieldset{padding:0 15px 10px 15px;} .summary-container fieldset{padding-bottom:5px;margin-top:4px;} legend.no-expand-all{padding:2px 15px 4px 10px;margin:0 0 0 -12px;} legend{color:#333333;padding:4px 15px 4px 10px;margin:4px 0 8px -12px;_margin-top:0px; border-top:1px solid #EDEDED;border-left:1px solid #EDEDED;border-right:1px solid #969696; border-bottom:1px solid #969696;background:#E7ECF0;font-weight:bold;'.
    I am facing issues in searching, my managed metadata service is not running, search results page throws internal error. Any Idea why this above error comes.
    P.S: We use windows authentication in our environment.

    Hi IMSunny,
    It seems you have solved this issue based on your another post.
    http://social.technet.microsoft.com/Forums/en-US/aa468ab0-1242-4ba8-97ea-1a3eb0c525c0/search-results-page-throws-internal-server-error?forum=sharepointgeneralprevious
    Thanks
    Daniel Yang
    TechNet Community Support

  • Error consuming Web service - content type text/xml;charset=utf-8 of the response message does not match the content type of the binding

    Hi all,
    We are trying to interact with Documentum server through DFS exposed WCF which communicates through port 9443 and we are provided with documentum issued Public Key certificates. We have successfully imported the certificates in client machine and configured
    the bindings as below in our .Net web application config file.
    <system.serviceModel>
    <bindings>
    <wsHttpBinding>       
    <binding
    name="ObjectServicePortBinding1">
    <security
    mode="Transport">
    <transport
    clientCredentialType="None"
    proxyCredentialType="None"
    realm=""
    />
    <message
    clientCredentialType="Certificate"
    algorithmSuite="Default"
    />
    </security>
    </binding>
    <binding
    name="QueryServicePortBinding">
    <security
    mode="Transport">
    <transport
    clientCredentialType="None"
    proxyCredentialType="None"
    realm=""
    />
    <message
    clientCredentialType="Certificate"
    algorithmSuite="Default"
    />
    </security>
    </binding>
    </wsHttpBinding>
    </bindings>
    Also, we set the message encoding as MTOM and the wcf client object initialization code snippet is as below,
    ObjectServicePortClient
    serviceClient = new
    ObjectServicePortClient(new
    WSHttpBinding("ObjectServicePortBinding1"),
    new
    EndpointAddress(UriUtil.ObjectServiceUri));
    if (serviceClient.Endpoint.Binding
    is
    WSHttpBinding)
       WSHttpBinding
    wsBinding = serviceClient.Endpoint.Binding as
    WSHttpBinding;
    wsBinding.MessageEncoding =
    "MTOM".Equals(transferMode) ?
    WSMessageEncoding.Mtom :
    WSMessageEncoding.Text;
    serviceClient.Endpoint.Behaviors.Add(new
    ServiceContextBehavior(Config.RepositoryName,
    Config.DocumentumUserName,
    Config.DocumentumPassword));
    When we execute the above code, we are getting error message as below,
    Exception: The content type text/xml;charset=utf-8 of the response message does not match the content type of the binding (multipart/related; type="application/xop+xml"). If using a custom encoder, be sure that the IsContentTypeSupported
    method is implemented properly. The first 407 bytes of the response were: '<?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope"><faultcode>S:VersionMismatch</faultcode><faultstring>Couldn't
    create SOAP message. Expecting Envelope in namespace http://schemas.xmlsoap.org/soap/envelope/, but got http://www.w3.org/2003/05/soap-envelope </faultstring></S:Fault></S:Body></S:Envelope>'
    Then, we changed the bindings as below
    <system.serviceModel>
    <bindings>
    <wsHttpBinding>       
    <binding
    name="ObjectServicePortBinding1">
    <security
    mode="Transport">
    <transport
    clientCredentialType="Certificate"
    proxyCredentialType="None"
    realm=""
    />
    <message
    clientCredentialType="Certificate"
    algorithmSuite="Default"
    />
    </security>
    </binding>
    <binding
    name="QueryServicePortBinding">
    <security
    mode="Transport">
    <transport
    clientCredentialType="
    Certificate"
    proxyCredentialType="None"
    realm=""
    />
    <message
    clientCredentialType="Certificate"
    algorithmSuite="Default"
    />
    </security>
    </binding>
    </wsHttpBinding>
    </bindings>
    We are getting another error message,
    Exception: The client certificate is not provided. Specify a client certificate in ClientCredentials.
    Any pointers on resolving this issue would be highly helpful.
    Thanks

    Hi Dhanasegaran,
      As per your case, the corresponding details which may guide you to resolve this issue:
    1. First of all, you can try to call the wcf service directly from the browser & check where it will point out the correct location.
    2. In config file ,Set IncludeExceptionDetailInFaults to true to enable exception information to flow to clients for debugging purposes .
    Set this to true only during development to troubleshoot a service like below :
    <serviceBehaviors>
      <behavior name="metadataAndDebugEnabled">
        <serviceDebug
          includeExceptionDetailInFaults="true"   
    />
        <serviceMetadata
          httpGetEnabled="true"
          httpGetUrl=""   
    />
      </behavior>
    </serviceBehaviors>
    3. I suggest you to change that <security mode ="TransportWithMessageCredential"> instead of <security mode ="Transport">
     for more information, refer the following link :
    https://msdn.microsoft.com/en-us/library/aa354508(v=vs.110).aspx

  • WCF returning "The content type text/html of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8)"

    I have a WCF service I am trying to run on a new installation of 64-bit Windows Server 2008 IIS. Although it runs fine on Windows 2003 IIS, it is throwing the error in the thread title, which appears to be a server config issue, but I am not sure. Googling and searching the MSDN forums did not turn up a solution. I tried running WCF Logging, but that didn't help either.
    Does anyone have any suggestions on how to solve this probelm?
    Here is the error:
    The content type text/html of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
    <title>500 - Internal server error.</title>
    <style type="text/css">

    I have the same issue on Windows 7 machine. The service works fine using a SoapUI client but a .Net client faisl to get a response.
    Hi,
    I have a WCF service which works perfectly when using SoapUI but throws error in my .Net client.
    {"The content type text/html; charset=UTF-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first
    1024 bytes of the response were: '<HTML><HEAD><link rel=\"alternate\" type=\"text/xml\" href=\"http://xyz.mysite.com/ysa/Broker.svc?disco\"/><STYLE type=\"text/css\">#content{ FONT-SIZE: 0.7em;
    PADDING-BOTTOM: 2em; MARGIN-LEFT: 30px}BODY{MARGIN-TOP: 0px; MARGIN-LEFT: 0px; COLOR: #000000; FONT-FAMILY: Verdana; BACKGROUND-COLOR: white}P{MARGIN-TOP: 0px; MARGIN-BOTTOM: 12px; COLOR: #000000; FONT-FAMILY: Verdana}PRE{BORDER-RIGHT: #f0f0e0 1px solid; PADDING-RIGHT:
    5px; BORDER-TOP: #f0f0e0 1px solid; MARGIN-TOP: -5px; PADDING-LEFT: 5px; FONT-SIZE: 1.2em; PADDING-BOTTOM: 5px; BORDER-LEFT: #f0f0e0 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: #f0f0e0 1px solid; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e5e5cc}.heading1{MARGIN-TOP:
    0px; PADDING-LEFT: 15px; FONT-WEIGHT: normal; FONT-SIZE: 26px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 3px; MARGIN-LEFT: -30px; WIDTH: 100%; COLOR: #ffffff; PADDING-TOP: 10px; FONT-FAMILY: Tahoma; BACKGROUND-COLOR: #003366}.intro{MARGIN-LEFT: -15px}</STYLE><TITLE>Broker
    Service</TITLE></HEAD><BODY><DIV id=\"content\"><P class=\"head'."}
    I have the same service hosted on my local machine and when I point to the local service I can execute the operation with no issues. The message encoding is Soap11. I tried changing to Soap12 but I get exact same error. Any ideas greatly appreciated.
    I do have windows Activation Features installed and I am using .Net Framework 4.
    Thanks
    Sofia Khatoon

  • Setting the Charset for outgoing mail in Mail

    When I send mails to windows-systems, the Outlook program gets the message with wrong characters. Especially of course the special danish characters, but also other information goes wrong. F.ex. grey lines hows up where I certainly did not put it!
    I have noticed, that the header of the message from Mail is like this:
    --Apple-Mail-1--672517002
    Content-Transfer-Encoding: 7bit
    Content-Type: text/plain;
    charset=US-ASCII;
    delsp=yes;
    format=flowed
    Sometimes like this:
    --Apple-Mail-9--596884052
    Content-Transfer-Encoding: quoted-printable
    Content-Type: text/plain;
    charset=UTF-8;
    delsp=yes;
    format=flowed
    When using the HTML functionality in Mail I get headers like this:
    --Apple-Mail-2--619494695
    Content-Transfer-Encoding: quoted-printable
    Content-Type: text/plain;
    charset=WINDOWS-1252;
    delsp=yes;
    format=flowed
    And the HTML-mails show's correctly!
    I guess it is an charset issue, but how can I control that maually?

    Open your Mail.app
    From the top of your screen choose Window>Connection Doctor.
    Double click on each server and make sure the password field is filled out, (your smtp server is likely to be missing the password)
    Enter the password into the field you find empty and close the preferences windows (saving changes if prompted) and close the Connection Doctor.
    Test to make sure you are fixed.
    If issues continue its going to be an issue with Keychain Access and you will need additional steps.
    EE

Maybe you are looking for