Re: CANONICALIZE how to use?

Jean Louis <[email protected]> Thu, 13 Apr 2017 17:31:32 +0300
Newsgroups gmane.lisp.clisp.general
Message-ID <[email protected]>
On Thu, Apr 13, 2017 at 10:28:52AM -0400, Sam Steingold wrote:
> > * Jean Louis <[email protected]> [2017-04-11 23:19:03 +0300]:
> >
> > If 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"

Thank you much, I can start from there.

I was under impression that č could be replaced by c, and š by s and
so on. That is often used for Internet URLs, so that search terms are
yet findable. Dropping is one solution, replacement or downgrade to
ASCII is better.


Jean

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
clisp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/clisp-list