dev-master
9999999-devStandalone library to test the whether a string's content would survive charset encoding to another encoding standard
MIT
The Requires
- php >=5.3.3
The Development Requires
by Adrie den Hartog
Standalone library to test the whether a string's content would survive charset encoding to another encoding standard
Encodingconversion dataloss checker, (*1)
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." */
Standalone library to test the whether a string's content would survive charset encoding to another encoding standard
MIT