@@ -309,24 +309,27 @@ private static function decodeByteSegment(
309309 $ readBytes [$ i ] = $ bits ->readBits (8 ); //(byte)
310310 }
311311 $ text = implode (array_map ('chr ' , $ readBytes ));
312- $ encoding = '' ;
313- if ($ currentCharacterSetECI == null ) {
314- // The spec isn't clear on this mode; see
315- // section 6.4.5: t does not say which encoding to assuming
316- // upon decoding. I have seen ISO-8859-1 used as well as
317- // Shift_JIS -- without anything like an ECI designator to
318- // give a hint.
312+ if ($ hints !== null && array_key_exists ('BINARY_MODE ' , $ hints ) && $ hints ['BINARY_MODE ' ]) {
313+ $ result .= $ text ;
314+ } else {
315+ $ encoding = '' ;
316+ if ($ currentCharacterSetECI == null ) {
317+ // The spec isn't clear on this mode; see
318+ // section 6.4.5: t does not say which encoding to assuming
319+ // upon decoding. I have seen ISO-8859-1 used as well as
320+ // Shift_JIS -- without anything like an ECI designator to
321+ // give a hint.
319322
320- try {
321- $ encoding = mb_detect_encoding ($ text , $ hints );
322- } catch (ValueError $ e ) {
323- $ encoding = mb_detect_encoding ($ text , mb_detect_order (), false );
324- }
325- } else {
326- $ encoding = $ currentCharacterSetECI ->name ();
327- }
328- $ result .= mb_convert_encoding ($ text , $ encoding ); //(new String(readBytes, encoding));
329- // $result .= $text; //(new String(readBytes, encoding));
323+ try {
324+ $ encoding = mb_detect_encoding ($ text , $ hints );
325+ } catch (ValueError $ e ) {
326+ $ encoding = mb_detect_encoding ($ text , mb_detect_order (), false );
327+ }
328+ } else {
329+ $ encoding = $ currentCharacterSetECI ->name ();
330+ }
331+ $ result .= mb_convert_encoding ($ text , $ encoding ); //(new String(readBytes, encoding));
332+ }
330333
331334 $ byteSegments = array_merge ($ byteSegments , $ readBytes );
332335 }
0 commit comments