Post by Jean LouisIf I am not mistaken CANONICALIZE could be used to get ASCII string
from "Some ČĆŠL ™bigbog file name.html" ?
Yes, but you don't really need it.
Here is what you can do:
--8<---------------cut here---------------start------------->8---
(defun drop-non-ascii-chars (string)
(if (every (lambda (c) (typep c charset:ascii)) string)
string
(let ((ascii #.(make-encoding :charset charset:ascii
:input-error-action :ignore
:output-error-action :ignore)))
(ext:convert-string-from-bytes
(ext:convert-string-to-bytes string ascii)
ascii))))
(drop-non-ascii-chars "Some ČĆŠL ™bigbog file name.html")
==> "Some L bigbog file name.html"
--8<---------------cut here---------------end--------------->8---
See http://www.clisp.org/impnotes/encoding.html
Bruno, is this The Right Way?
PS. `:input-error-action :ignore` is not really necessary
Post by Jean LouisIn documentation I cannot see what is first argument and what is
second argument.
The doc http://clisp.org/impnotes/macros3.html#canonicalize
Post by Jean Louis(EXT:CANONICALIZE value functions &KEY (test 'EQL) (max-iter 1024))
will call functions on value until it stabilizes under test (which
should be a valid HASH-TABLE-TEST) and return the stabilized value
and the number of iterations the stabilization required.
IOW,
(ext:canonicalize "Some ČĆŠL ™bigbog file name.html"
'(drop-non-ascii-chars))
Jean, how would you clarify the doc?
--
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1504
http://steingoldpsychology.com http://www.childpsy.net http://www.memritv.org
http://iris.org.il http://islamexposedonline.com http://no2bds.org
Those who value Life above Freedom are destined to lose both.