emacs-pretest-bug
[Top][All Lists]
Advanced

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

Re: is this a bug? string-equal seems to act strangely


From: Kenichi Handa
Subject: Re: is this a bug? string-equal seems to act strangely
Date: Thu, 11 Jan 2007 21:50:06 +0900
User-agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/22.0.92 (i686-pc-linux-gnu) MULE/5.0 (SAKAKI)

In article <address@hidden>, Chris <address@hidden> writes:

> Hex 80 is equal to octal 200, so why does string-equal give these results?
  ELISP> (string-equal "\200\x80" "\x80\200")
>   t

  ELISP> (string-equal "\200" "\x80")
>   nil

This is another weirdness of multibyte/unibyte mixture.  I
don't remember why but the Lisp reader reads "\200" as a
unibyte string but if \x notation appears in a string, it is
read as a multibyte string.  So, both "\200\x80" and
"\x80\200" are read into the same multibyte string
"\x80\x80".  Thus, the first form returns t.  But, as two
strings differ in multibyteness in the second form, nil is
returned.

FYI, (compare-strings "\200" 0 1 "\x80" 0 1) returns t
because it adjusts multibyteness before comparing.

---
Kenichi Handa
address@hidden




reply via email to

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