I just noticed that on drupal.org, .patch files are being served up using content encoding Windows-1252. This is a problem because if you include UTF-8 characters in your patch they will be displayed incorrectly.
Actually, it may just be that no encoding is being set by the server, and the browser just assumes Windows-1252 for some reason, but I see this on Chrome/Firefox on a Linux machine, and on Edge with a Windows machine, so it's consistent.
You can look at any patch file on drupal.org and check the page info in the browser to see this.
But most patch files don't have UTF-8 characters, so they look fine.
For example of a patch that contains UTF-8, take a look at:
https://www.drupal.org/node/2879270#comment-12337440 →
and click on
https://www.drupal.org/files/issues/usps_first_class-2879270-5.patch →
It will display mangled, like this:
diff --git a/shipping/uc_usps/uc_usps.module b/shipping/uc_usps/uc_usps.module
index 8a18b1b..dffacb3 100644
--- a/shipping/uc_usps/uc_usps.module
+++ b/shipping/uc_usps/uc_usps.module
@@ -370,7 +370,7 @@ function uc_usps_quote($products, $details, $method) {
foreach ($package->Postage as $postage) {
$classid = (string)$postage['CLASSID'];
if ($classid === '0') {
- if ((string)$postage->MailService == "First-Class Mail® Parcel") {
+ if ((string)$postage->MailService == "First-Class Package Service - Retailâ„¢") {
$classid = 'zeroParcel';
}
elseif ((string)$postage->MailService == "First-Class Mail® Letter") {
See how the trademark symbols have odd characters next to them?
If you use wget to download this patch it looks fine - it's only the display in the browser that's wrong.
I suggest forcing the encoding to UTF-8 by sending text/plain with Content-Type: text/plain; charset=utf-8
.