Giter Club home page Giter Club logo

Comments (12)

MikeEdgar avatar MikeEdgar commented on August 13, 2024 1

@sharukhshaik126 you'll need to provide the name of the character encoding when you create the EDIStreamReader.

Something like this (I am only guessing on the encoding in this example):

EDIStreamReader ediReader = inputFactory.createEDIStreamReader(inputStream, "ISO-8859-1");

from staedi.

sharukhshaik126 avatar sharukhshaik126 commented on August 13, 2024 1

Let me try with different encoding "UTF-8" and ISO-8859-1 , Thanks @MikeEdgar

from staedi.

MikeEdgar avatar MikeEdgar commented on August 13, 2024 1

Great news! Thanks for the update @sharukhshaik126 . I'll go ahead and close the issue, but please re-open if this still isn't resolved in your opinion and we'll discuss further.

from staedi.

MikeEdgar avatar MikeEdgar commented on August 13, 2024

Hi @sharukhshaik126 , what is the character encoding of the data you are reading? You can use one of the overloads of EDIInputFactory#createEDIStreamReader to provide the correct encoding for your input.

from staedi.

sharukhshaik126 avatar sharukhshaik126 commented on August 13, 2024

@MikeEdgar actually when i tried to parse edi file with accent marks it throw below exception :
Unable to Stream EDI File : Error parsing input in segment NM1 at position 767, element 2
the same segment with accent marks working fine in windows env and it throws above exception in linux env, even if not specify char set encoding to edistreamreader class.

my code block :

EDIInputFactory inputFactory = EDIInputFactory.newFactory();
inputFactory.setProperty(EDIInputFactory.EDI_IGNORE_EXTRANEOUS_CHARACTERS, true);
InputStream inputStream = new FileInputStream(sourceFile);
EDIStreamReader ediReader = inputFactory.createEDIStreamReader(inputStream);

from staedi.

MikeEdgar avatar MikeEdgar commented on August 13, 2024

FYI that the default is UTF-8 if nothing is given.

from staedi.

sharukhshaik126 avatar sharukhshaik126 commented on August 13, 2024

Thanks , will try to define exact charset encoding to parse it. will update you here.

from staedi.

MikeEdgar avatar MikeEdgar commented on August 13, 2024

@sharukhshaik126 any luck?

from staedi.

sharukhshaik126 avatar sharukhshaik126 commented on August 13, 2024

@MikeEdgar No in linux still it throws exception after setting encoding to UTF-8
fail to parse edi file : /tmp/test/Halin_C_frdsw.txt | UTF-8
io.xlate.edi.stream.EDIStreamException: Error parsing input in segment NM1 at position 767, element 2
at io.xlate.edi.internal.stream.StaEDIStreamReader.lambda$executeTask$1(StaEDIStreamReader.java:186)
at io.xlate.edi.internal.ThrowingRunnable.run(ThrowingRunnable.java:19)
at io.xlate.edi.internal.stream.StaEDIStreamReader.executeTask(StaEDIStreamReader.java:181)
at io.xlate.edi.internal.stream.StaEDIStreamReader.nextEvent(StaEDIStreamReader.java:212)
at io.xlate.edi.internal.stream.StaEDIStreamReader.next(StaEDIStreamReader.java:241)
at com.mage.edireader.EDIFileParser.main(EDIFileParser.java:79)
Caused by: java.nio.charset.MalformedInputException: Input length = 1
at java.base/java.nio.charset.CoderResult.throwException(CoderResult.java:274)
at io.xlate.edi.internal.stream.tokenization.Lexer.readCharacter(Lexer.java:339)
at io.xlate.edi.internal.stream.tokenization.Lexer.readCharacterUnchecked(Lexer.java:313)
at io.xlate.edi.internal.stream.tokenization.Lexer.parse(Lexer.java:192)
at io.xlate.edi.internal.stream.tokenization.Lexer.parse(Lexer.java:174)
at io.xlate.edi.internal.ThrowingRunnable.run(ThrowingRunnable.java:17)
... 4 more
Exception in thread "main" io.xlate.edi.stream.EDIStreamException: Exception flushing output stream in segment NM1 at position 767, element 2
at io.xlate.edi.internal.stream.StaEDIStreamWriter.flush(StaEDIStreamWriter.java:240)
at io.xlate.edi.internal.stream.StaEDIStreamWriter.close(StaEDIStreamWriter.java:230)
at com.mage.edireader.EDIFileParser.main(EDIFileParser.java:187)
Caused by: java.io.IOException: Stream Closed
at java.base/java.io.FileOutputStream.writeBytes(Native Method)
at java.base/java.io.FileOutputStream.write(FileOutputStream.java:354)
at java.base/sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:233)
at java.base/sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:312)
at java.base/sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:316)
at java.base/sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:153)
at java.base/java.io.OutputStreamWriter.flush(OutputStreamWriter.java:251)
at io.xlate.edi.internal.stream.StaEDIStreamWriter.flush(StaEDIStreamWriter.java:237)
... 2 more

from staedi.

MikeEdgar avatar MikeEdgar commented on August 13, 2024

Did you also try with ISO-8859-1 ? As far as I can tell it does include í and é characters.

from staedi.

MikeEdgar avatar MikeEdgar commented on August 13, 2024

@sharukhshaik126 can you possibly provide a test file without sensitive data that I can use to reproduce the issue? Using the sample text you gave originally I haven't been able to trigger any errors.

from staedi.

sharukhshaik126 avatar sharukhshaik126 commented on August 13, 2024

@MikeEdgar after using charger encode ad ISO-8859-1
The EDI file parsed successfully

from staedi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.