[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Differences between identical strings in Emacs lisp
From: |
Pascal J. Bourguignon |
Subject: |
Re: Differences between identical strings in Emacs lisp |
Date: |
Tue, 07 Apr 2015 02:10:09 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Jürgen Hartmann <juergen_hartmann_@hotmail.com> writes:
> What is the difference between the string represented by the constant "\xBA"
> and the result of (concat '(#xBA))?
(mapcar 'multibyte-string-p (list "\xBA" (concat '(#xBA))))
--> (nil t)
string-equal (and therefore string=) don't ignore the multibyte property
of a string.
You can use:
(mapcar 'string-as-unibyte (list "\xBA" (concat '(#xBA))))
--> ("\272" "\302\272")
to see the difference.
Now, it's hard to say how to "solve" this problem, basically, you asked
for it: "\xBA" is not a valid way to write a string containing masculine
ordinal.
I guess you could extract back the bytes, and recreate the string
correctly:
(map 'string 'identity (map 'list 'identity "\xBA"))
--> "º"
(string= (map 'string 'identity (map 'list 'identity "\xBA"))
(concat '(#xBA)))
--> t
(On the other hand, one might argue that having both unibyte and
multibyte strings in a lisp implementation is not a good idea, and
there's the opportunity for a big refactoring and simplification).
--
__Pascal Bourguignon__ http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk
- Differences between identical strings in Emacs lisp, Jürgen Hartmann, 2015/04/06
- Re: Differences between identical strings in Emacs lisp,
Pascal J. Bourguignon <=
- [Solved] RE: Differences between identical strings in Emacs lisp, Jürgen Hartmann, 2015/04/07
- Re: [Solved] RE: Differences between identical strings in Emacs lisp, Eli Zaretskii, 2015/04/07
- RE: [Solved] RE: Differences between identical strings in Emacs lisp, Jürgen Hartmann, 2015/04/07
- Re: [Solved] RE: Differences between identical strings in Emacs lisp, Eli Zaretskii, 2015/04/07
- RE: [Solved] RE: Differences between identical strings in Emacs lisp, Jürgen Hartmann, 2015/04/08
- Re: [Solved] RE: Differences between identical strings in Emacs lisp, Eli Zaretskii, 2015/04/08
- Re: [Solved] RE: Differences between identical strings in Emacs lisp, Stefan Monnier, 2015/04/08
- RE: [Solved] RE: Differences between identical strings in Emacs lisp, Jürgen Hartmann, 2015/04/09
- Re: [Solved] RE: Differences between identical strings in Emacs lisp, Stefan Monnier, 2015/04/09
- Re: [Solved] RE: Differences between identical strings in Emacs lisp, Eli Zaretskii, 2015/04/09