[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/src/fns.c
From: |
Kenichi Handa |
Subject: |
[Emacs-diffs] Changes to emacs/src/fns.c |
Date: |
Sun, 09 Feb 2003 03:37:36 -0500 |
Index: emacs/src/fns.c
diff -c emacs/src/fns.c:1.329 emacs/src/fns.c:1.330
*** emacs/src/fns.c:1.329 Tue Jan 14 18:12:31 2003
--- emacs/src/fns.c Sun Feb 9 03:37:36 2003
***************
*** 1035,1040 ****
--- 1035,1071 ----
return make_multibyte_string (buf, SCHARS (string), nbytes);
}
+
+ /* Convert STRING to a multibyte string without changing each
+ character codes. Thus, characters 0200 trough 0237 are converted
+ to eight-bit-control characters, and characters 0240 through 0377
+ are converted eight-bit-graphic characters. */
+
+ Lisp_Object
+ string_to_multibyte (string)
+ Lisp_Object string;
+ {
+ unsigned char *buf;
+ int nbytes;
+ int i;
+
+ if (STRING_MULTIBYTE (string))
+ return string;
+
+ nbytes = parse_str_to_multibyte (SDATA (string), SBYTES (string));
+ /* If all the chars are ASCII, they won't need any more bytes
+ once converted. In that case, we can return STRING itself. */
+ if (nbytes == SBYTES (string))
+ return string;
+
+ buf = (unsigned char *) alloca (nbytes);
+ bcopy (SDATA (string), buf, SBYTES (string));
+ str_to_multibyte (buf, nbytes, SBYTES (string));
+
+ return make_multibyte_string (buf, SCHARS (string), nbytes);
+ }
+
+
/* Convert STRING to a single-byte string. */
Lisp_Object
***************
*** 1140,1145 ****
--- 1171,1194 ----
}
return string;
}
+
+ DEFUN ("string-to-multibyte", Fstring_to_multibyte, Sstring_to_multibyte,
+ 1, 1, 0,
+ doc: /* Return a multibyte string with the same individual chars as
STRING.
+ If STRING is multibyte, the resutl is STRING itself.
+ Otherwise it is a newly created string, with no text properties.
+ Characters 0200 through 0237 are converted to eight-bit-control
+ characters of the same character code. Characters 0240 through 0377
+ are converted to eight-bit-control characters of the same character
+ codes. */)
+ (string)
+ Lisp_Object string;
+ {
+ CHECK_STRING (string);
+
+ return string_to_multibyte (string);
+ }
+
DEFUN ("copy-alist", Fcopy_alist, Scopy_alist, 1, 1, 0,
doc: /* Return a copy of ALIST.
***************
*** 5545,5550 ****
--- 5594,5600 ----
defsubr (&Sstring_make_unibyte);
defsubr (&Sstring_as_multibyte);
defsubr (&Sstring_as_unibyte);
+ defsubr (&Sstring_to_multibyte);
defsubr (&Scopy_alist);
defsubr (&Ssubstring);
defsubr (&Ssubstring_no_properties);
- [Emacs-diffs] Changes to emacs/src/fns.c, Richard M. Stallman, 2003/02/04
- [Emacs-diffs] Changes to emacs/src/fns.c, Francesco Potortì, 2003/02/06
- [Emacs-diffs] Changes to emacs/src/fns.c,
Kenichi Handa <=
- [Emacs-diffs] Changes to emacs/src/fns.c, Kenichi Handa, 2003/02/10
- [Emacs-diffs] Changes to emacs/src/fns.c, Dave Love, 2003/02/14
- [Emacs-diffs] Changes to emacs/src/fns.c, Kenichi Handa, 2003/02/16
- [Emacs-diffs] Changes to emacs/src/fns.c, Stefan Monnier, 2003/02/22