[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/file/browser/file.txt Change the default charset of plain text to utf-8.

Yusei Tahara yusei at domen.cx
Wed Jan 31 03:35:27 EST 2007


Log message for revision 72271:
  Change the default charset of plain text to utf-8.
  I'm sorry that I missed to fix this test.
  

Changed:
  U   Zope3/trunk/src/zope/app/file/browser/file.txt

-=-
Modified: Zope3/trunk/src/zope/app/file/browser/file.txt
===================================================================
--- Zope3/trunk/src/zope/app/file/browser/file.txt	2007-01-30 23:49:31 UTC (rev 72270)
+++ Zope3/trunk/src/zope/app/file/browser/file.txt	2007-01-31 08:35:25 UTC (rev 72271)
@@ -205,8 +205,8 @@
       </form>
   ...
 
-Files of type text/plain without any charset information can only contain ASCII
-text.
+Files of type text/plain without any charset information can contain UTF-8 text.
+So you can use ASCII text.
 
   >>> print http(r"""
   ... POST /sample.txt/edit.html HTTP/1.1
@@ -223,7 +223,7 @@
   ...
   ... This is a sample text file.
   ...
-  ... It can only contain US-ASCII characters.
+  ... It can contain US-ASCII characters.
   ... -----------------------------165727764114325486311042046845
   ... Content-Disposition: form-data; name="UPDATE_SUBMIT"
   ...
@@ -251,7 +251,7 @@
   ...<textarea cols="60" id="field.data" name="field.data" rows="15"
   >This is a sample text file.
   <BLANKLINE>
-  It can only contain US-ASCII characters.</textarea></div>
+  It can contain US-ASCII characters.</textarea></div>
   ...
           <div class="controls">
             <input type="submit" value="Refresh" />
@@ -274,14 +274,13 @@
   <BLANKLINE>
   This is a sample text file.
   <BLANKLINE>
-  It can only contain US-ASCII characters.
+  It can contain US-ASCII characters.
 
 
 Non-ASCII Text Files
 --------------------
 
-If we want an uploaded text file to contain non-ASCII characters, we have to
-explicitly specify the charset.
+We can also use non-ASCII charactors in text file.
 
   >>> print http("""
   ... POST /sample.txt/edit.html HTTP/1.1
@@ -292,13 +291,13 @@
   ... -----------------------------165727764114325486311042046845
   ... Content-Disposition: form-data; name="field.contentType"
   ...
-  ... text/plain; charset=UTF-8
+  ... text/plain
   ... -----------------------------165727764114325486311042046845
   ... Content-Disposition: form-data; name="field.data"
   ...
   ... This is a sample text file.
   ...
-  ... It can now contain UTF-8 characters, e.g. \xe2\x98\xbb (U+263B BLACK SMILING FACE).
+  ... It can contain non-ASCII(UTF-8) characters, e.g. \xe2\x98\xbb (U+263B BLACK SMILING FACE).
   ... -----------------------------165727764114325486311042046845
   ... Content-Disposition: form-data; name="UPDATE_SUBMIT"
   ...
@@ -321,12 +320,12 @@
   <BLANKLINE>
         <div class="row">
   ...<input class="textType" id="field.contentType" name="field.contentType"
-            size="20" type="text" value="text/plain; charset=UTF-8"  />...
+            size="20" type="text" value="text/plain"  />...
         <div class="row">
   ...<textarea cols="60" id="field.data" name="field.data" rows="15"
   >This is a sample text file.
   <BLANKLINE>
-  It can now contain UTF-8 characters, e.g. ... (U+263B BLACK SMILING FACE).</textarea></div>
+  It can contain non-ASCII(UTF-8) characters, e.g. ... (U+263B BLACK SMILING FACE).</textarea></div>
   ...
           <div class="controls">
             <input type="submit" value="Refresh" />
@@ -345,17 +344,17 @@
   >>> print response
   HTTP/1.1 200 Ok
   Content-Length: ...
-  Content-Type: text/plain; charset=UTF-8
+  Content-Type: text/plain
   Last-Modified: ...
   <BLANKLINE>
   This is a sample text file.
   <BLANKLINE>
-  It can now contain UTF-8 characters, e.g. ... (U+263B BLACK SMILING FACE).
+  It can contain non-ASCII(UTF-8) characters, e.g. ... (U+263B BLACK SMILING FACE).
 
   >>> u'\u263B' in response.getBody().decode('UTF-8')
   True
 
-You can use other charsets too.  Note that the browser form is always UTF-8.
+And you can explicitly specify the charset. Note that the browser form is always UTF-8.
 
   >>> print http("""
   ... POST /sample.txt/edit.html HTTP/1.1
@@ -443,7 +442,7 @@
   ... -----------------------------165727764114325486311042046845
   ... Content-Disposition: form-data; name="field.contentType"
   ...
-  ... text/plain
+  ... text/plain; charset=US-ASCII
   ... -----------------------------165727764114325486311042046845
   ... Content-Disposition: form-data; name="field.data"
   ...
@@ -468,10 +467,10 @@
         <div>
           <h3>Change a file</h3>
   <BLANKLINE>
-          <p>The character set you specified (ASCII) cannot encode all characters in text.</p>
+          <p>The character set you specified (US-ASCII) cannot encode all characters in text.</p>
   <BLANKLINE>
         <div class="row">
-  ...<input class="textType" id="field.contentType" name="field.contentType" size="20" type="text" value="text/plain"  />...
+  ...<input class="textType" id="field.contentType" name="field.contentType" size="20" type="text" value="text/plain; charset=US-ASCII"  />...
         <div class="row">
   ...<textarea cols="60" id="field.data" name="field.data" rows="15" >This is a slightly changed sample text file.
   <BLANKLINE>
@@ -552,7 +551,7 @@
   Content-Type: text/html;charset=utf-8
   <BLANKLINE>
   ...
-     <li>The character set specified in the content type (ASCII) does not match file content.</li>
+     <li>The character set specified in the content type (UTF-8) does not match file content.</li>
   ...
 
 



More information about the Zope3-Checkins mailing list