Add support for different encodings#2385
Merged
juliusknorr merged 2 commits intomasterfrom May 17, 2022
Merged
Conversation
7f9ffe4 to
69c3236
Compare
vinicius73
reviewed
May 11, 2022
de3fb09 to
4a725a3
Compare
Member
|
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? |
vinicius73
approved these changes
May 12, 2022
207a4da to
2919658
Compare
Member
|
@Raudius Could you do a rebase to update the branch rather then merge? That would make the commit history linear and a bit cleaner :) |
Member
5299d57 to
ff8f19a
Compare
juliusknorr
reviewed
May 16, 2022
Comment on lines
47
to
58
| $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); |
Member
There was a problem hiding this comment.
Small nitpick on the code style 😉 I guess we currently don't run php-cs-fixer on the tests directory.
Suggested change
| $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
juliusknorr
approved these changes
May 16, 2022
Member
juliusknorr
left a comment
There was a problem hiding this comment.
Just a minor code style comment left on the tests, otherwise LGTM
cdd653a to
86a2c38
Compare
Signed-off-by: Raul <raul@nextcloud.com>
Signed-off-by: Raul <raul@nextcloud.com>
86a2c38 to
42a448c
Compare
Member
|
/backport to stable24 |
Member
|
/backport to stable23 |
Member
|
/backport to stable22 |
This was referenced May 17, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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