emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: address@hidden: Locale Dependent Downcasing in smtpmail]


From: Chong Yidong
Subject: Re: address@hidden: Locale Dependent Downcasing in smtpmail]
Date: Tue, 03 Apr 2007 12:30:37 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.96 (gnu/linux)

Eli Zaretskii <address@hidden> writes:

>> nndoc.el:511:   (intern (downcase (mail-header-strip encoding))))))
>> nndoc.el:905:   subtype (downcase (match-string 2 content-type))
>> rfc2047.el:674: (concat "=?" (downcase (symbol-name mime-charset))
>> 
>> Failing Cases:
>> (downcase "ISO-8859-1") ==> ıso-8859-1
>> (downcase "text/plain") ==> text-plaın
>
> Perhaps we should have something like downcase-ascii for such
> situations.

Yeah.

How about the following approach?  At the beginning of characters.el,
save the standard case table (which AFAICT hasn't been modified at
that point), as a variable ascii-case-table.  Then downcase-ascii can
use it.

*** emacs/lisp/international/characters.el.~1.65.~      2007-03-05 
02:00:16.000000000 -0500
--- emacs/lisp/international/characters.el      2007-04-03 12:18:07.000000000 
-0400
***************
*** 43,48 ****
--- 43,54 ----
  
  ;;; Predefined categories.
  
+ ;; Save ASCII case table.
+ 
+ (require 'case-table)
+ (defvar ascii-case-table (copy-case-table (standard-case-table))
+   "Case table for the ASCII character set.")
+ 
  ;; For each character set.
  
  (define-category ?a "ASCII graphic characters 32-126 (ISO646 IRV:1983[4/0])")
*** emacs/lisp/subr.el.~1.549.~ 2007-03-19 14:37:19.000000000 -0400
--- emacs/lisp/subr.el  2007-04-03 12:26:04.000000000 -0400
***************
*** 2804,2809 ****
--- 2804,2819 ----
        ;; Reconstruct a string from the pieces.
        (setq matches (cons (substring string start l) matches)) ; leftover
        (apply #'concat (nreverse matches)))))
+ 
+ (defun downcase-ascii (string)
+   "Convert ASCII argument to lower case and return that.
+ The argument may be a character or string.  The result has the same type.
+ The argument object is not altered--the value is a copy."
+   (let ((old-case-table (current-case-table)))
+     (unwind-protect
+       (progn (set-case-table ascii-case-table)
+              (downcase string))
+       (set-case-table old-case-table))))

  ;;;; invisibility specs
  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]