(eval-when-compile (require 'cl))
(require 'mcharset)
+(require 'static)
+(require 'poem)
-(eval-and-compile
+(eval-when-compile
(autoload 'mime-content-type-parameter "mime-parse")
(autoload 'mime-read-Content-Type "mime-parse"))
+(static-if (fboundp 'string-to-list)
+ (defalias 'gettext-string-to-list 'string-to-list)
+ ;; Rely on `string-to-char-list' emulation is provided in poem.
+ (defalias 'gettext-string-to-list 'string-to-char-list))
+
(defvar gettext-gmo-endian 1234)
(defvar gettext-message-domain-to-catalog-alist nil)
(defvar gettext-default-message-domain "emacs")
(goto-char pos))
(nreverse strings)))
-(defmacro gettext-parse-Content-Type (&optional header)
- (require 'path-util)
- (if (module-installed-p 'mime-parse)
- (list 'with-temp-buffer
- (list 'insert header)
- '(mime-content-type-parameter
- (mime-read-Content-Type)
- "charset"))
- 'gettext-default-mime-charset))
+(defun gettext-parse-Content-Type (&optional header)
+ "Return the MIME charset of PO file."
+ (with-temp-buffer
+ (insert header)
+ (if (require 'mime-parse nil 'noerror)
+ (mime-content-type-parameter (mime-read-Content-Type) "charset")
+ (goto-char (point-min))
+ (if (re-search-forward
+ "^\"Content-Type: *text/plain;[ \t]*charset=\\([^\\]+\\)"
+ nil t)
+ (find-mime-charset-by-charsets
+ (list (buffer-substring (match-beginning 1) (match-end 1))))
+ gettext-default-mime-charset))))
(defun gettext-mapcar* (function &rest args)
"Apply FUNCTION to successive cars of all ARGS.