Skip to content

Commit a440514

Browse files
authored
Merge pull request #1264 from p4bl04p/master
Converter txt para xml
2 parents 2b39e84 + 03c54af commit a440514

3 files changed

Lines changed: 494 additions & 22 deletions

File tree

src/Common/ValidTXT.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class ValidTXT
1919
{
2020
public const LOCAL = "LOCAL";
2121
public const LOCAL_V12 = "LOCAL_V12";
22+
public const LOCAL_V13 = "LOCAL_V13";
2223
public const SEBRAE = "SEBRAE";
2324

2425
/**
@@ -32,8 +33,10 @@ public static function loadStructure(float $version = 4.00, string $baselayout =
3233
$comp = '';
3334
if (strtoupper($baselayout) === 'SEBRAE') {
3435
$comp = '_sebrae';
35-
} elseif (strtoupper($baselayout) === 'LOCAL_V12') {
36+
} elseif (strtoupper($baselayout) === self::LOCAL_V12) {
3637
$comp = '_v1.2';
38+
} elseif (strtoupper($baselayout) === self::LOCAL_V13) {
39+
$comp = '_v1.3';
3740
}
3841
$file = $path . '/txtstructure' . ($version * 100) . $comp . '.json';
3942
if (!is_file($file)) {
@@ -125,15 +128,15 @@ public static function isValid(string $txt, string $baselayout = self::LOCAL): a
125128
}
126129
$newfield = preg_replace(
127130
'/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]' .
128-
'|[\x00-\x7F][\x80-\xBF]+' .
129-
'|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*' .
130-
'|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})' .
131-
'|[\xE0-\xEF](([\x80-\xBF](?![\x80-\xBF]))|(?![\x80-\xBF]{2})|[\x80-\xBF]{3,})/S',
131+
'|[\x00-\x7F][\x80-\xBF]+' .
132+
'|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*' .
133+
'|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})' .
134+
'|[\xE0-\xEF](([\x80-\xBF](?![\x80-\xBF]))|(?![\x80-\xBF]{2})|[\x80-\xBF]{3,})/S',
132135
'?',
133136
$field
134137
);
135138
$newfield = preg_replace('/\xE0[\x80-\x9F][\x80-\xBF]' .
136-
'|\xED[\xA0-\xBF][\x80-\xBF]/S', '?', $newfield);
139+
'|\xED[\xA0-\xBF][\x80-\xBF]/S', '?', $newfield);
137140
if ($field != $newfield) {
138141
$errors[] = "ERRO: ($num) Existem caracteres não UTF-8, não permitidos, "
139142
. "no campo [" . htmlentities($newfield) . "]";

0 commit comments

Comments
 (0)