1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* Determine the number of screen columns needed for a character.
4 Copyright (C) 2006-2007, 2010-2011 Free Software Foundation, Inc.
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
27 #include "localcharset.h"
35 /* In UTF-8 locales, use a Unicode aware width function. */
36 const char *encoding = locale_charset ();
37 if (STREQ (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0 ,0))
39 /* We assume that in a UTF-8 locale, a wide character is the same as a
41 return uc_width (wc, encoding);
45 /* Otherwise, fall back to the system's wcwidth function. */
49 return wc == 0 ? 0 : iswprint (wc) ? 1 : -1;