Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Character set windows-1252 should be CP1252 under Unix #245

Open
supercosh opened this issue Jan 15, 2024 · 4 comments
Open

Character set windows-1252 should be CP1252 under Unix #245

supercosh opened this issue Jan 15, 2024 · 4 comments
Labels
help wanted Extra attention is needed

Comments

@supercosh
Copy link

In /src/PaymentPart/Output/FpdfOutput/FpdfOutput.php, the following code is found:

return iconv('UTF-8', 'windows-1252', $text) ?: '';

Under unix, the character set should be called "CP1252", since "windows-1252" is unknown on most systems. Also I'm not sure if the code is correct, since the funktion name is "toUtf8", but what the code does, is to convert "from" UTF8.

The occurence of "windows-1252" is in several files.

@sprain
Copy link
Owner

sprain commented Jan 15, 2024

Thanks for reporting.

Do you experience any problems because of this or is it just "cosmetics"?

@supercosh
Copy link
Author

It just throws a PHP warnings every time a QR bill is created; the generated qr bill however seems to be valid. So it's not a severe problem, it just got me curious because of the growing logs. A solution could perhaps be to get a list of the character sets on the system and chose one of them?

@sprain sprain added the help wanted Extra attention is needed label Jan 18, 2024
@sprain
Copy link
Owner

sprain commented Jan 18, 2024

Could you post the exacting warning that you get? This might help to improve this.

@supercosh
Copy link
Author

Here's the warning

2024-01-26 15:54:25 warning: iconv(): Wrong encoding, conversion from "UTF-8" to "windows-1252" is not allowed
Trace:
iconv [internal], line ??
Sprain\SwissQrBill\PaymentPart\Output\TcPdfOutput\TcPdfOutput::toUtf8() /httpdocs/vendor/sprain/swiss-qr-bill/src/PaymentPart/Output/TcPdfOutput/TcPdfOutput.php, line 358
Sprain\SwissQrBill\PaymentPart\Output\TcPdfOutput\TcPdfOutput::setFurtherInformationElement() /httpdocs/vendor/sprain/swiss-qr-bill/src/PaymentPart/Output/TcPdfOutput/TcPdfOutput.php, line 286
Sprain\SwissQrBill\PaymentPart\Output\TcPdfOutput\TcPdfOutput::setContentElement() /httpdocs/vendor/sprain/swiss-qr-bill/src/PaymentPart/Output/TcPdfOutput/TcPdfOutput.php, line 233
Sprain\SwissQrBill\PaymentPart\Output\TcPdfOutput\TcPdfOutput::addFurtherInformationContent() /httpdocs/vendor/sprain/swiss-qr-bill/src/PaymentPart/Output/TcPdfOutput/TcPdfOutput.php, line 213
Sprain\SwissQrBill\PaymentPart\Output\TcPdfOutput\TcPdfOutput::getPaymentPart() /httpdocs/vendor/sprain/swiss-qr-bill/src/PaymentPart/Output/TcPdfOutput/TcPdfOutput.php, line 89

And here is the code:

$qr = QrBill::create();
$qr->setCreditor(CombinedAddress::create(...));
$qr->setCreditorInformation(CreditorInformation::create(...));
$qr->setUltimateDebtor(StructuredAddress::createWithoutStreet(...));
$qr->setPaymentAmountInformation(PaymentAmountInformation::create('CHF', $total));
$qr->setPaymentReference(PaymentReference::create(PaymentReference::TYPE_QR, $qr_nummer));

$output = new TcPdfOutput($qr, 'de', $pdf);
$output->getPaymentPart();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants