comparison src/fns.c @ 96502:ff7196ae78c9

(Fstring_to_unibyte): Delete the arg ACCEPT-LATIN-1.
author Kenichi Handa <handa@m17n.org>
date Fri, 04 Jul 2008 02:22:42 +0000
parents 0073930415c3
children 1307c33f5e9a
comparison
equal deleted inserted replaced
96501:919775e9f3bf 96502:ff7196ae78c9
1130 1130
1131 return string_to_multibyte (string); 1131 return string_to_multibyte (string);
1132 } 1132 }
1133 1133
1134 DEFUN ("string-to-unibyte", Fstring_to_unibyte, Sstring_to_unibyte, 1134 DEFUN ("string-to-unibyte", Fstring_to_unibyte, Sstring_to_unibyte,
1135 1, 2, 0, 1135 1, 1, 0,
1136 doc: /* Return a unibyte string with the same individual chars as STRING. 1136 doc: /* Return a unibyte string with the same individual chars as STRING.
1137 If STRING is unibyte, the result is STRING itself. 1137 If STRING is unibyte, the result is STRING itself.
1138 Otherwise it is a newly created string, with no text properties, 1138 Otherwise it is a newly created string, with no text properties,
1139 where each `eight-bit' character is converted to the corresponding byte. 1139 where each `eight-bit' character is converted to the corresponding byte.
1140 If STRING contains a non-ASCII, non-`eight-bit' character, 1140 If STRING contains a non-ASCII, non-`eight-bit' character,
1141 an error is signaled. 1141 an error is signaled. */)
1142 If the optional 2nd arg ACCEPT-LATIN-1 is non-nil, a Latin-1 character 1142 (string)
1143 doesn't cause an error, but is converted to a byte of same code. */) 1143 Lisp_Object string;
1144 (string, accept_latin_1)
1145 Lisp_Object string, accept_latin_1;
1146 { 1144 {
1147 CHECK_STRING (string); 1145 CHECK_STRING (string);
1148 1146
1149 if (STRING_MULTIBYTE (string)) 1147 if (STRING_MULTIBYTE (string))
1150 { 1148 {
1151 EMACS_INT chars = SCHARS (string); 1149 EMACS_INT chars = SCHARS (string);
1152 unsigned char *str = (unsigned char *) xmalloc (chars); 1150 unsigned char *str = (unsigned char *) xmalloc (chars);
1153 EMACS_INT converted = str_to_unibyte (SDATA (string), str, chars, 1151 EMACS_INT converted = str_to_unibyte (SDATA (string), str, chars, 0);
1154 ! NILP (accept_latin_1)); 1152
1155 if (converted < chars) 1153 if (converted < chars)
1156 error ("Can't convert the %dth character to unibyte", converted); 1154 error ("Can't convert the %dth character to unibyte", converted);
1157 string = make_unibyte_string (str, chars); 1155 string = make_unibyte_string (str, chars);
1158 xfree (str); 1156 xfree (str);
1159 } 1157 }