No charset on response for patch & text files
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #2922638. -->
Reported by: [tr](https://www.drupal.org/user/202830)
>>>
<p>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.</p>
<p>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.</p>
<p>You can look at any patch file on drupal.org and check the page info in the browser to see this.<br>
But most patch files don't have UTF-8 characters, so they look fine.</p>
<p>For example of a patch that contains UTF-8, take a look at:</p>
<p><a href="https://www.drupal.org/node/2879270#comment-12337440">https://www.drupal.org/node/2879270#comment-12337440</a><br>
and click on<br>
<a href="https://www.drupal.org/files/issues/usps_first_class-2879270-5.patch">https://www.drupal.org/files/issues/usps_first_class-2879270-5.patch</a></p>
<p>It will display mangled, like this:</p>
<pre>diff --git a/shipping/uc_usps/uc_usps.module b/shipping/uc_usps/uc_usps.module<br>index 8a18b1b..dffacb3 100644<br>--- a/shipping/uc_usps/uc_usps.module<br>+++ b/shipping/uc_usps/uc_usps.module<br>@@ -370,7 +370,7 @@ function uc_usps_quote($products, $details, $method) {<br> foreach ($package->Postage as $postage) {<br> $classid = (string)$postage['CLASSID'];<br> if ($classid === '0') {<br>- if ((string)$postage->MailService == "First-Class Mail® Parcel") {<br>+ if ((string)$postage->MailService == "First-Class Package Service - Retail™") {<br> $classid = 'zeroParcel';<br> }<br> elseif ((string)$postage->MailService == "First-Class Mail® Letter") {</pre><p>
See how the trademark symbols have odd characters next to them?<br>
If you use <strong>wget</strong> to download this patch it looks fine - it's only the display in the browser that's wrong.</p>
<p>I suggest forcing the encoding to UTF-8 by sending text/plain with <code>Content-Type: text/plain; charset=utf-8</code>.</p>
issue