2017 © Pedro Peláez
 

library encoding-conversion-dataloss-checker

Standalone library to test the whether a string's content would survive charset encoding to another encoding standard

image

adrie-dh/encoding-conversion-dataloss-checker

Standalone library to test the whether a string's content would survive charset encoding to another encoding standard

  • Friday, April 22, 2016
  • by adrie-dh
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Encodingconversion dataloss checker, (*1)

Build Status, (*2)

Provides the tools to check for dataloss during encoding. For instance UTF-8 to ISO-8859-1 will ensure that some characters might not make the conversion., (*3)

Also comes with a simple substring wrapper which allows you to provide exact feedback in your frontend regarding the problematic characters., (*4)

Examples:, (*5)

$testString = 'Ma võin klaasi süüa, 是紅, see ei tee mulle midagi. 是紅. And then some.';
$tester = new EncodingConversionDataLossChecker('UTF-8', 'ISO-8859-1');
$diffArray = $tester->diagnose($testString);

/* $diffArray:
array(2) {
  [0]=>
  array(3) {
    ["startPos"]=>
    int(21)
    ["characters"]=>
    string(6) "是紅"
    ["length"]=>
    int(2)
  }
  [1]=>
  array(3) {
    ["startPos"]=>
    int(50)
    ["characters"]=>
    string(6) "是紅"
    ["length"]=>
    int(2)
  }
}
*/

$testString = 'In most of europe the standard currency is the euro (€), it has € as a symbol.';
$tester = new EncodingConversionDataLossChecker('UTF-8', 'ISO-8859-1');
$diffArray = $tester->diagnose($testString);

/* $diffArray:
array(2) {
  [0]=>
  array(3) {
    ["startPos"]=>
    int(53)
    ["characters"]=>
    string(3) "€"
    ["length"]=>
    int(1)
  }
  [1]=>
  array(3) {
    ["startPos"]=>
    int(64)
    ["characters"]=>
    string(3) "€"
    ["length"]=>
    int(1)
  }
}
*/

$testString = 'Ma võin klaasi süüa, 是紅, see ei tee mulle midagi. 是紅. And then some.';
$tester = new EncodingConversionDataLossChecker('UTF-8', 'ISO-8859-1');
$diffArray = $tester->diagnose($testString);
$wrappedHtml = $tester->subStringWrap($testString, $diffArray, '

', ', (*6)

'); /* $wrappedHtml: string(93) "Ma võin klaasi süüa,

是紅, (*7)

, see ei tee mulle midagi.

是紅, (*8)

. And then some." */

The Versions

22/04 2016

dev-master

9999999-dev

Standalone library to test the whether a string's content would survive charset encoding to another encoding standard

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by Adrie den Hartog