Converting from CP1252 (Windows) to ISO 8859-1 doesn't work with java.nio?

Hi
I'm trying to write some code that checks whether an InputStream contains only characters with a given encoding. I'm using java.nio for that. For tests, I downloaded some character set examples from http://www.columbia.edu/kermit/csettables.html
When creating the CharsetDecoder, I want to get all errors:
    Charset charset = Charset.forName( encoding );
    CharsetDecoder decoder = charset.newDecoder();
    decoder.onMalformedInput( CodingErrorAction.REPORT );
    decoder.onUnmappableCharacter( CodingErrorAction.REPORT );I then read an InputStream and try to convert it. If that fails, it can't contain the desired encoding:
    boolean isWellEncoded = true;
    ByteBuffer inBuffer = ByteBuffer.allocate( 1024 );
    ReadableByteChannel channel = Channels.newChannel( inputStream );
    while ( channel.read( inBuffer ) != -1 )
      CharBuffer decoded = null;
      try
        inBuffer.flip();
        decoded = decoder.decode( inBuffer );
      catch ( MalformedInputException ex )
        isWellEncoded = false;
      catch ( UnmappableCharacterException ex )
        isWellEncoded = false;
      catch ( CharacterCodingException ex )
        isWellEncoded = false;
      if ( decoded != null )
        LOG.debug( decoded.toString() );
      if ( !isWellEncoded )
        break;
      inBuffer.compact();
    channel.close();
    return isWellEncoded;Now I want to check whether a file containing Windows 1252 characters is ISO-8859-1. From my point of view, the code above should fail when it gets to the Euro symbol (decimal 128), since that's not defined in ISO-8859-1.
But all I get is a ? character instead:
(})  125  07/13  175  7D                 RIGHT CURLY BRACKET, RIGHT BRACE
(~)  126  07/14  176  7E                 TILDE
[?]  128  08/00  200  80  EURO SYMBOL
[?]  130  08/02  202  82  LOW 9 SINGLE QUOTEI also tried to replace the faulty character, using
    decoder.onUnmappableCharacter( CodingErrorAction.REPLACE );
    decoder.replaceWith("!");but I still get the question marks.
I'm probably doing something fundamentally wrong, but I dont get it :-)
Any help is greatly appreciated!
Eric

As a suggestion....create a complete example demonstrating the problem. It shouldn't have channel in it since that wouldn't appear to be the problem (decoding is.) You should create the byte array in the example code - populate it with the byte sequence that you think should work. And your code should then demonstrate that it doesn't. Then post that.

Similar Messages

  • HTTP-Receiver: Code page conversion error from UTF-8 to ISO-8859-1

    Hello experts,
    In one of our interfaces we are using the payload manipulation of the HTTP receiver channel to change the payload code page from UTF-8 to ISO-8859-1. And from time to time we are facing the following error:
    u201CCode page conversion error UTF-8 from system code page to code page ISO-8859-1u201D
    Iu2019m quite sure that this error occurs because of non-ISO-8859-1 characters in the processed message. And here comes my question:
    Is it possible to change the error behaviour of the code page converter, so that the error will be ignored?
    Perhaps the converter could replace the disruptive character with e.g. u201C#u201D?
    Thank you in advance.
    Best regards,
    Thomas

    Hello.
    I'm not 100% sure if this will help, but it's a good Reading material on the subject (:
    [How to Work with Character Encodings in Process Integration (NW7.0)|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/502991a2-45d9-2910-d99f-8aba5d79fb42]
    The part of the XSLT / Java mapping might come in handy in your situation.
    you can check for problematic chars in the code.
    Good luck,
    Imanuel Rahamim.

  • Codepage coverting error utf-8 from System codepage to iso-8859-1 (PI 7.1)

    Hello Experts,
    In our Prcess, we receive an Idoc from an IS-U system and then we send this Idoc with some Header-Information via http-Adapter to a Seeburger System.
    In the outbound communication Channel we have a XI Payload manipulation with xml-Code iso-8859-1.
    We get the Error: Codepage coverting error utf-8 from System codepage to iso-8859-1, and only for this Idoc, where othe similar Idocs runs correctly.
    Is it possible, that the Idoc contains non-utf-8 chars so the error occurs?
    PS: another XI in our landscape uses a http-Channel with the same configuration in a similar process, an it work, so guess the Problem is not in the communication channel.
    thanks,
    best regards

    > Is it possible, that the Idoc contains non-utf-8 chars so the error occurs?
    A would rather think, that there could be any non-iso-8859-1 character be in the IDoc. For example an czech or polish character.

  • Mail Sender - Encoding (I need to change from UTF-8 to ISO-8859-1)

    Hi,
    I'm getting data from email (in ms exchange) using the Mail Sender Adapter.
    In the e-mails exists characters as ç (ccedil), ã (atilde), õ (otilde) and others. The XI cannot read this characters because the encode in XML is UTF-8.
    How I do to change the encode in XI from UTF-8 to ISO-8859-1 ?
    Thank you!

    Unfortunately most mail server do not apply the codepage to the content type of a mail.
    In this case you have to set the content type with help of the MessageTransformBean:
    Transform.ContentType      text/plain;charset="ISO-8859-1"
    Regards
    Stefan

  • Windows movie maker dose not seem to work with itunes music.

    Windows movie maker dose not seem to work with itunes music anymore. Hear is what happend in a nut shell.
    For reasons I can not explain I had to reinstall all my software on my Vista HP notbook. But I only had one why of saving my data music,photos. I had to use my flash drive to save everything as my DVD recoder would not work right at the time.
    So I save everything I needed and then did the deed then when that was all done and everything was working right again. I put all my photos and music back to my computer. All my music or aleast most of my music is from itunes some music is from CD I do not have anymore.
    My question is when I go to put music with my movie or slideshow with Windows movie maker. A box pops up and tells me that this song dose not have the right codec but it also tell me did I download the right codec. I have know idea what its talking about. Movie Maker worked fine with itunse music before the reinstall. I am thinking I did not save the music right though the music plays great on itunes but just will not import right to my movie project. I am at a lose for words can someone please help me shed some well needed light on this all the help I can get would be a God send thank you.

    this happens to me too can someone please tell us what is going on?

  • My Custom Converter Doesn't Work With DataModel

    Hi,
    I have this simple object with its custom converter taken from the Core JSF Book. It works fine, but when I put it in DataModel, somehow it didn't get updated. I don't put the whole codes here, only the important parts.
    Any1 knows what is the reason? I have been looking for an answer but I haven't found one. Plz help.
    public class CreditCard {
    private String number;
    public CreditCard(String number) { this.number = number; }
    public String toString() { return number; }
    public class CreditCardConverter implements Converter, Serializable {
    private String separator;
    public void setSeparator(String newValue) { separator = newValue; }
    public Object getAsObject(............);
    return new CreditCard(builder.toString());
    public String getAsString(..............)
    throws ConverterException {
    return result.toString();
    public class MyBackBean{
    private DataModel creditCardDataModel;
    private static final CreditCard[] ccs = {
    new CreditCard("1111 111 111 111"),
    new CreditCard("2222 222 222 222")
    public DataModel getCards(){
    if (creditCardDataModel == null) {
    creditCardDataModel = new ArrayDataModel(ccs);
    return creditCardDataModel;
    <h:dataTable value="#{myBackBean.cards}" var="card">
    <h:column>
    <h:inputText id="card" value="#{card}"/>
    </h:column>
    </h:dataTable>
    Edited by: JW77 on Dec 3, 2009 12:47 AM

    Please explain.
    What does "cellcom line doesn't work with my iPhone" mean?
    What are you trying?  What is happening?
    Where did you buy the iphone?
    Any info abnout your issue at all?

  • AT-AO-10 doesn´t work with Windows 2000

    I have an AT-AO-10 board that doesn’t work with Windows 2000. I have reserved two IRQs for legacy devices (non plug and play) in BIOS. The AT-AO-10 has got assigned these IRQs, a DMA and a base address that are free, and there aren’t any hardware conflicts, but the board doesn't pass the MAX's text.
    In Windows 'Information System', the board is shown in 'Forced hardware', but I don’t know that is a problem.
    If the board is unplugged, error messages are the same.

    Hello;
    You didn't mention what version of the NI-DAQ driver you are using over there. Anyway, my suggestion to you is to uninstall the NI-DAQ driver you have installed, remove the board, reboot the machine, download and install the latest NI-DAQ version (6.9.3) from NI web site.
    Try the installation with the new driver, and if that is still not working, the best bet is to try the same installation on a different machine to double check if the hardware is not defective.
    Regards
    Filipe A.
    Applications Engineer
    National Instruments

  • After upgrading from ITunes6 on ITunes 7 my videos doesn´t work

    after upgrading from ITunes6 on ITunes 7 my videos doesn´t work. there are no error messages, popups or ballons. songs are no problem, only the videos?!
    Can somebody help me?
    Thanks
    Cross

    hmmmm. let's try checking to see if they will still play in your current version of QuickTime.
    in itunes, right-click on one of the videos that is causing the grief, and select "Show in Windows Explorer".
    right click the icon of the file in the Explorer window that comes up and select "Open With ...", and try to open it with your QuickTime player. does it play there or do you get funny business with that too?

  • My i pod nano first generation doesn't work with windows 8

    My i pod nano first generation doesn't work with windows 8

    Howdy yvesmd,
    Thanks for using the Apple Support Communities.
    If your iPod nano is not being recognized in iTunes on your Windows computer, then I'd like you to please follow the directions in the link below.
    Apple - Support - iPod - iPod nano Troubleshooting
    Cheers,
    Alex H.

  • PSE 10 installed on windows 7 desktop and recently updated on windows laptop.  now PSE doesn't work on either machine.  How can this be fixed?

    PSE 10 installed on windows 7 desktop and recently updated on windows laptop.  now PSE doesn't work on either machine.  How can this be fixed?

    uninstall pse 10 (properly using the adobe uninstaller).
    clean - Use the CC Cleaner Tool to solve installation problems | CC, CS3-CS6
    then try reinstalling using the adobe installation file(s).
    if you see an activation count error while trying to reinstall contact adobe support, https://helpx.adobe.com/contact.html
    and ask for an activation count reset.

  • Iam from Yemen we have CDMA carrier called Yemen mobile I bought an iPad from the US CDMA works with Verizon when I got to Yemen doesn't work with the carrier Yemen mobile and  both carriers verizon and Yemen mobile work by the CDMA system don't know whey

    Iam from Yemen we have CDMA carrier called Yemen mobile I bought an iPad from the US CDMA works with Verizon when I got to Yemen doesn't work with the carrier Yemen mobile and  both carriers verizon and Yemen mobile work by the CDMA system don't know whey can anyone help me please..

    A Verizon-model iPad can only work on CDMA with Verizon. You cannot use it with any other carrier. Apple, to my knowledge, has not released the iPad in Yemen, so there is no iPad you can use with any carrier there that works only on CDMA. You would need to find a GSM carrier and then get an unlocked GSM iPad.
    Regards.

  • I have upgraded Acrobat Standard from version 8 through time until I am currently using version X, which doesn't work with Office 2013.  Can I upgrade to version Standard XI?

    Over the years I have upgraded Acrobat Standard from version 8 to currently working with version X.
    However, since getting a new laptop it doesn't work with Office 2013.
    Can I upgrade to Standard XI?

    Upgrade pricing now only applies to version 9 and X. So if you have a retail serial number for X, you should be able to upgrade. (Or consider subscription).

  • I have 3 macs. 2 are Lion, 1 I left Snow leopard so I can access data from my old Quicken Application that doesn't work with Lion. If I move to iCloud, will I no longer be able to access my MobileMe email on the Snow Leopard mac?

    I have 3 macs. 2 are Lion, but 1 I left Snow leopard so I can access data from my old Quicken Application that doesn't work with Lion. If I move to iCloud, will I no longer be able to access my MobileMe email on the Snow Leopard mac?

    What version of word do you have? The TS3938 sounds like it's a PowerPC app- written for an old architecture that is no longer supported in Lion. If this is the case, your files are fine- you just need a newer version of word that will run in Lion in order to open them. The newest version (2011) should be readily available anywhere, and has worked fine for me ever since I switched to Lion on release day....

  • How can I order an iphone 6 and pick it up from one of the apple stores in London. It doesn't work with reserve and pick up because the 64 gb is never in stock.

    How can I order an iphone 6 and pick it up from one of the apple stores in London??? It doesn't work with reserve and pick up because the 64 gb is never in stock.

    Thank you for replying.    Yes I deleted the old email address..   

  • I am using InDesign CS 3.0.1 with Windows XP. I am getting a new computer with Windows 8.1. Will my version work with this? If not can I get an upgrade?

    I am using InDesign CS 3.0.1 with Windows XP. I am getting a new computer with Windows 8.1. Will my version work with this? If not can I get an upgrade?

    Probably won't work. You can buy a full license for CS6 which is already two versions and soon to be three out of date or you can subscribe to Creative Cloud.

Maybe you are looking for

  • Using Twitter on iPad Air

    Forgive me if this has been brought up before, but I couldn't find it in a search. I got an iPad Air a couple of days ago, and have been trying to use it. I have noticed a problem when using Twitter - it might be related to the general problem that I

  • Is it possible to assign user-defined data elements to table control?

    Hi SDN, Is it possible to assign a user defined data element other than basic data types in table control column.

  • CS4 Installs but then INdesign , Illustrator won't open

    Hello, Can anyone offer me advice on this issue with CS4? My DVDs Install ok but when trying to open InDesign and Illustrator I get the message, 'sorry InDesign needs to close' I then send an error report to Microsoft - but the product didn't open at

  • How To Recover Accidentally Deleted Bins

    It's probably (hopefully) a quick fix, but I can't find help on this topic anywhere. I'm working in cs6 and I didn't realize that I had deleted the bin until after I saw the footage missing in the sequence.  I already closed and reopened premeire so

  • Why won't the store open?

    When I open iTunes & go the the store it says it's not connected to the Internet, whn I am. How do I fix that problem ?