|
Packit Service |
4684c1 |
/* Look at first character in UTF-32 string.
|
|
Packit Service |
4684c1 |
Copyright (C) 2002, 2006-2007, 2009-2020 Free Software Foundation, Inc.
|
|
Packit Service |
4684c1 |
Written by Bruno Haible <bruno@clisp.org>, 2002.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
This program is free software: you can redistribute it and/or
|
|
Packit Service |
4684c1 |
modify it under the terms of either:
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
* the GNU Lesser General Public License as published by the Free
|
|
Packit Service |
4684c1 |
Software Foundation; either version 3 of the License, or (at your
|
|
Packit Service |
4684c1 |
option) any later version.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
or
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
* the GNU General Public License as published by the Free
|
|
Packit Service |
4684c1 |
Software Foundation; either version 2 of the License, or (at your
|
|
Packit Service |
4684c1 |
option) any later version.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
or both in parallel, as here.
|
|
Packit Service |
4684c1 |
This program is distributed in the hope that it will be useful,
|
|
Packit Service |
4684c1 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
4684c1 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
4684c1 |
Lesser General Public License for more details.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
You should have received a copy of the GNU Lesser General Public License
|
|
Packit Service |
4684c1 |
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#include <config.h>
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#if defined IN_LIBUNISTRING
|
|
Packit Service |
4684c1 |
/* Tell unistr.h to declare u32_mbtouc_unsafe as 'extern', not
|
|
Packit Service |
4684c1 |
'static inline'. */
|
|
Packit Service |
4684c1 |
# include "unistring-notinline.h"
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* Specification. */
|
|
Packit Service |
4684c1 |
#include "unistr.h"
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#if !HAVE_INLINE
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
int
|
|
Packit Service |
4684c1 |
u32_mbtouc_unsafe (ucs4_t *puc, const uint32_t *s, size_t n)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
uint32_t c = *s;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (c < 0xd800 || (c >= 0xe000 && c < 0x110000))
|
|
Packit Service |
4684c1 |
*puc = c;
|
|
Packit Service |
4684c1 |
else
|
|
Packit Service |
4684c1 |
/* invalid multibyte character */
|
|
Packit Service |
4684c1 |
*puc = 0xfffd;
|
|
Packit Service |
4684c1 |
return 1;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#endif
|