jcs ratpoison hax
1/*
2 * Copyright (C) 2017 Jeremie Courreges-Anglas <jca@wxcvcbn.org>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301, USA.
18 */
19
20#include "ratpoison.h"
21
22#ifdef HAVE_LANGINFO_CODESET
23# include <langinfo.h>
24#endif
25
26int utf8_locale;
27
28int
29utf8_check_locale(void)
30{
31#ifdef HAVE_LANGINFO_CODESET
32 utf8_locale = !strcmp (nl_langinfo (CODESET), "UTF-8");
33#endif
34 return utf8_locale;
35}
36
37int
38isu8char(char c)
39{
40 return utf8_locale && (c) & 0xC0;
41}
42
43int
44isu8start(char c)
45{
46 return utf8_locale && ((c) & 0xC0) == 0xC0;
47}
48
49int
50isu8cont(char c)
51{
52 return utf8_locale && ((c) & 0xC0) == 0x80;
53}