1 /* Copyright (C) 2014 Free Software Foundation, Inc.
3 * This library is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU Lesser General Public License as
5 * published by the Free Software Foundation, either version 3 of the
6 * License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library. If not, see
15 * <http://www.gnu.org/licenses/>.
29 #include "libguile/_scm.h"
30 #include "libguile/validate.h"
32 #include "libguile/unicode.h"
36 SCM_DEFINE (scm_char_to_formal_name
, "char->formal-name", 1, 0, 0,
38 "Return the formal all-upper-case unicode name of @var{ch},\n"
39 "as a string. If the character has no name, return @code{#f}.")
40 #define FUNC_NAME s_scm_char_to_formal_name
42 char buf
[UNINAME_MAX
+ 1];
44 SCM_VALIDATE_CHAR (1, ch
);
46 memset(buf
, 0, UNINAME_MAX
+ 1);
48 if (unicode_character_name (SCM_CHAR (ch
), buf
))
49 return scm_from_latin1_string (buf
);
55 SCM_DEFINE (scm_formal_name_to_char
, "formal-name->char", 1, 0, 0,
57 "Return the character whose formal all-upper-case unicode name is\n"
58 "@var{name}, or @code{#f} if no such character is known.")
59 #define FUNC_NAME s_scm_formal_name_to_char
64 SCM_VALIDATE_STRING (1, name
);
66 c_name
= scm_to_latin1_string (name
);
67 ret
= unicode_name_character (c_name
);
70 return ret
== UNINAME_INVALID
? SCM_BOOL_F
: SCM_MAKE_CHAR (ret
);
75 scm_load_unicode (void)
77 #ifndef SCM_MAGIC_SNARFER
78 #include "libguile/unicode.x"
83 scm_init_unicode (void)
85 scm_c_register_extension ("libguile-" SCM_EFFECTIVE_VERSION
,
87 (scm_t_extension_init_func
)scm_load_unicode
,