-
Notifications
You must be signed in to change notification settings - Fork 91
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
Add support for different encodings #2385
Conversation
7f9ffe4
to
69c3236
Compare
de3fb09
to
4a725a3
Compare
As we are using mbstring functions, it is important to define it in --- a/composer.json
+++ b/composer.json
@@ -17,7 +17,8 @@
}
],
"require": {
- "php": "^7.3|^8.0"
+ "php": "^7.3|^8.0",
+ "ext-mbstring": "*"
},
"scripts": { What do you think? |
207a4da
to
2919658
Compare
@Raudius Could you do a rebase to update the branch rather then merge? That would make the commit history linear and a bit cleaner :) |
5299d57
to
ff8f19a
Compare
$detected_encoding = $this->encodingService->detectEncoding(file_get_contents($file)); | ||
if ($this->isSupportedEncoding($encoding)) { | ||
$this->assertNotNull($detected_encoding); | ||
} | ||
|
||
$original_order = mb_detect_order(); | ||
$this->assertNotFalse(mb_detect_order($encoding)); | ||
|
||
$detected_encoding = $this->encodingService->detectEncoding(file_get_contents($file)); | ||
$this->assertEquals($encoding, $detected_encoding); | ||
|
||
mb_detect_order($original_order); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nitpick on the code style 😉 I guess we currently don't run php-cs-fixer on the tests directory.
$detected_encoding = $this->encodingService->detectEncoding(file_get_contents($file)); | |
if ($this->isSupportedEncoding($encoding)) { | |
$this->assertNotNull($detected_encoding); | |
} | |
$original_order = mb_detect_order(); | |
$this->assertNotFalse(mb_detect_order($encoding)); | |
$detected_encoding = $this->encodingService->detectEncoding(file_get_contents($file)); | |
$this->assertEquals($encoding, $detected_encoding); | |
mb_detect_order($original_order); | |
$detectedEncoding = $this->encodingService->detectEncoding(file_get_contents($file)); | |
if ($this->isSupportedEncoding($encoding)) { | |
$this->assertNotNull($detectedEncoding); | |
} | |
$originalOrder = mb_detect_order(); | |
$this->assertNotFalse(mb_detect_order($encoding)); | |
$detectedEncoding = $this->encodingService->detectEncoding(file_get_contents($file)); | |
$this->assertEquals($encoding, $detectedEncoding); | |
mb_detect_order($originalOrder); |
ff8f19a
to
749cc0a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a minor code style comment left on the tests, otherwise LGTM
cdd653a
to
86a2c38
Compare
Signed-off-by: Raul <[email protected]>
Signed-off-by: Raul <[email protected]>
86a2c38
to
42a448c
Compare
/backport to stable24 |
/backport to stable23 |
/backport to stable22 |
Summary
Previously we would just assume files would use UTF-8. Now we make sure to convert files to UTF-8 when we open them. Without configuration just a small set of encodings are supported:
More encodings can be configured via the PHP config value:
mbstring.detect_order