Comments (7)
Uhm, it's strange!
Does it happen also when you var_dump the array?
What's the charset in UNB?
Could you send me an example via email?
from edifact.
Yes, it does also happen if I var_dump the $parser->get()
array.
The EDI file I was testing with was using a file encoding of UTF-8, however this is literally the first time I work with this file format, so I have no idea what you mean by "UNB".
This EDI file gave me this error There's a not printable character on line...
seven times (once for each line with a swedish character, I'm assuming)
I have two example EDI files, however, and the second one was using Windows 1252 encoding instead of UTF-8. I tried this one as well, and it no longer gave me the not printable character
error, so at first I thought it worked, but then I scrolled down and found that it hadn't worked.
I'm not sure if I am allowed to send you one of the EDI files, so we'll have to hold off on that for now.
from edifact.
Try this, load your file with file_get_contents in a variable $text
$p = new Parser();
$p->setStripRegex("/[\x01-\x1F\x7F-\x9F]/"); //or something less restricting
$p->loadString($text);
from edifact.
I'm already sort of doing that. Here's my entire debug file currently
<!DOCTYPE html>
<html lang="sv">
<head>
<meta charset="UTF8">
</head>
<body>
<pre><?php
require( __DIR__ . "/EDI/Parser.php" );
$edi = file_get_contents( "in.edi" );
$parser = new \EDI\Parser($edi);
var_dump( $parser->get() );
?></pre>
</body>
</html>
I'll try your above code too, one moment
EDIT: Tried your above code, no change. Also tried changing the pattern a bunch, including these
$parser->setStripRegex("[\x01-\x1]");
$parser->setStripRegex("[\x7F-\x9F]");
$parser->setStripRegex("//");
$parser->setStripRegex("/MATCH NOTHING PLEASE/");
none of those worked.
from edifact.
If you var dump $edi you see the correct chars?
If you generate an anonymized version I can look at it, because with other diacritics I see it works as expected...
from edifact.
Yes, I do see the correct chars then
I've asked to see if I was allowed to share a file, so I'm sending it to you via email
from edifact.
To anyone else reading this: After some emails back and forth we found the solution.
use utf8_decode
on the file contents
$file = utf8_decode(file_get_contents($path));
$parser = new EDI\Parser($file);
// ... and so on
And then, use utf8_encode($var)
every time you read a value from the resulting array.
This will fix it.
from edifact.
Related Issues (20)
- Release 0.5.0 not available via Composer HOT 2
- Possibility to have IDs instead of name as output from Interpreter::prepare HOT 5
- CDR read HOT 4
- Problems reading RFF segment from EDI-File HOT 1
- Array to string conversion, if an epty array met. HOT 1
- X12 HOT 6
- Package ramsey/array_column is abandoned HOT 2
- Trouble understanding how to get the data we need HOT 5
- Segment is ambiguous HOT 1
- Elements with maxrepeat > 1 should be considered arrays when parsed as json HOT 6
- Reader doesn't return full multi-line texts HOT 4
- Multiple SG2 segments not allowed HOT 8
- Does IFTMIN:S:93A supported? HOT 5
- UTF8 characters handling in input edi file HOT 15
- How to create edi document with .edi extension for healthcare HOT 4
- readEdiSegmentDTM for SG12 HOT 5
- File has multiple messages HOT 6
- question marks are not parsed correctly HOT 5
- Fatal error on integer-value segments for Encoder HOT 2
- Reader cannot be init with a null param HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from edifact.