Skip to content

Commit 4813b29

Browse files
committed
update libmojibake -> utf8proc 1.2 (closes JuliaLang#10654); replace wcwidth by utf8proc_charwidth (fixes JuliaLang#3721, closes JuliaLang#6939)
1 parent b535042 commit 4813b29

19 files changed

+81
-408
lines changed

.gitmodules

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
[submodule "deps/openspecfun"]
88
path = deps/openspecfun
99
url = git://github.com/JuliaLang/openspecfun.git
10-
[submodule "deps/libmojibake"]
11-
path = deps/libmojibake
12-
url = git://github.com/JuliaLang/libmojibake.git
10+
[submodule "deps/utf8proc"]
11+
path = deps/utf8proc
12+
url = git://github.com/JuliaLang/utf8proc.git

Make.inc

+6-8
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ USE_SYSTEM_SUITESPARSE=0
3535
USE_SYSTEM_RMATH=0
3636
USE_SYSTEM_LIBUV=0
3737
USE_SYSTEM_UTF8PROC=0
38-
USE_SYSTEM_MOJIBAKE=0
38+
USE_SYSTEM_UTF8PROC=0
3939
USE_SYSTEM_LIBGIT2=0
4040

4141
# Link to the LLVM shared library
@@ -594,14 +594,12 @@ else
594594
LIBUV_INC = $(JULIAHOME)/deps/libuv/include
595595
endif
596596

597-
ifeq ($(USE_SYSTEM_MOJIBAKE), 1)
598-
LIBMOJIBAKE = -lmojibake
597+
ifeq ($(USE_SYSTEM_UTF8PROC), 1)
598+
LIBUTF8PROC = -lutf8proc
599+
UTF8PROC_INC = /usr/include
599600
else
600-
ifeq ($(USE_SYSTEM_UTF8PROC), 1)
601-
LIBMOJIBAKE = -lutf8proc
602-
else
603-
LIBMOJIBAKE = $(build_libdir)/libmojibake.a
604-
endif
601+
LIBUTF8PROC = $(build_libdir)/libutf8proc.a
602+
UTF8PROC_INC = $(JULIAHOME)/deps/utf8proc
605603
endif
606604

607605
# OS specific stuff

base/string.jl

-1
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,6 @@ startswith(a::Array{UInt8,1}, b::Array{UInt8,1}) =
541541

542542
## character column width function ##
543543

544-
charwidth(c::Char) = max(0,Int(ccall(:wcwidth, Int32, (UInt32,), c)))
545544
strwidth(s::AbstractString) = (w=0; for c in s; w += charwidth(c); end; w)
546545
strwidth(s::ByteString) = Int(ccall(:u8_strwidth, Csize_t, (Ptr{UInt8},), s.data))
547546
# TODO: implement and use u8_strnwidth that takes a length argument

base/utf8proc.jl

+10-7
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import Base: show, showcompact, ==, hash, string, symbol, isless, length, eltype
66
export isgraphemebreak
77

88
# also exported by Base:
9-
export normalize_string, graphemes, is_valid_char, is_assigned_char,
9+
export normalize_string, graphemes, is_valid_char, is_assigned_char, charwidth,
1010
islower, isupper, isalpha, isdigit, isnumber, isalnum,
1111
iscntrl, ispunct, isspace, isprint, isgraph, isblank
1212

1313
# whether codepoints are valid Unicode
14-
is_valid_char(c) = (0x0 <= c <= 0x110000) && Bool(ccall(:utf8proc_codepoint_valid, Cuchar, (Int32,), c))
15-
is_valid_char(c::Char) = is_valid_char(UInt32(c))
14+
is_valid_char(c::Union(UInt8,UInt16,UInt32,Char)) = Bool(ccall(:utf8proc_codepoint_valid, Cuchar, (UInt32,), c))
15+
is_valid_char(c::Integer) = (0x0 <= c <= 0x110000) && is_valid_char(UInt32(c))
1616

1717
# utf8 category constants
1818
const UTF8PROC_CATEGORY_CN = 0
@@ -116,10 +116,13 @@ end
116116

117117
############################################################################
118118

119-
# returns UTF8PROC_CATEGORY code in 1:30 giving Unicode category
119+
charwidth(c::Char) = Int(ccall(:utf8proc_charwidth, Cint, (UInt32,), c))
120+
121+
############################################################################
122+
123+
# returns UTF8PROC_CATEGORY code in 0:30 giving Unicode category
120124
function category_code(c)
121-
UInt32(c) > 0x10FFFF && return 0x0000 # see utf8proc_get_property docs
122-
return unsafe_load(ccall(:utf8proc_get_property, Ptr{UInt16}, (Int32,), c))
125+
return ccall(:utf8proc_category, Cint, (UInt32,), c)
123126
end
124127

125128
is_assigned_char(c) = category_code(c) != UTF8PROC_CATEGORY_CN
@@ -176,7 +179,7 @@ end
176179
# iterators for grapheme segmentation
177180

178181
isgraphemebreak(c1::Char, c2::Char) =
179-
ccall(:utf8proc_grapheme_break, Bool, (Char, Char), c1, c2)
182+
ccall(:utf8proc_grapheme_break, Bool, (UInt32, UInt32), c1, c2)
180183

181184
immutable GraphemeIterator{S<:AbstractString}
182185
s::S # original string (for generation of SubStrings)

contrib/windows/msys_build.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@ echo 'override LIBLAPACKNAME = $(LIBBLASNAME)' >> Make.user
180180
# Remaining dependencies:
181181
# libuv since its static lib is no longer included in the binaries
182182
# openlibm since we need it as a static library to work properly
183-
# mojibake since its headers are not in the binary download
183+
# utf8proc since its headers are not in the binary download
184184
echo 'override STAGE1_DEPS = uv' >> Make.user
185-
echo 'override STAGE2_DEPS = mojibake' >> Make.user
185+
echo 'override STAGE2_DEPS = utf8proc' >> Make.user
186186
echo 'override STAGE3_DEPS = ' >> Make.user
187187
make -C deps get-uv
188188

@@ -197,8 +197,8 @@ if [ -n "$USEMSVC" ]; then
197197
# Since we don't have a static library for openlibm
198198
echo 'override UNTRUSTED_SYSTEM_LIBM = 0' >> Make.user
199199

200-
# Compile libuv and mojibake without -TP first, then add -TP
201-
make -C deps install-uv install-mojibake
200+
# Compile libuv and utf8proc without -TP first, then add -TP
201+
make -C deps install-uv install-utf8proc
202202
cp usr/lib/uv.lib usr/lib/libuv.a
203203
echo 'override CC += -TP' >> Make.user
204204
else

deps/Makefile

+31-31
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ include $(JULIAHOME)/Make.inc
1111
# if you are adding a new target, it can help to copy an similar, existing target
1212
#
1313
# autoconf configure-driven scripts: llvm pcre arpack fftw unwind gmp mpfr patchelf uv
14-
# custom Makefile rules: openlibm Rmath-julia dsfmt suitesparse-wrapper suitesparse lapack openblas mojibake objconv
14+
# custom Makefile rules: openlibm Rmath-julia dsfmt suitesparse-wrapper suitesparse lapack openblas utf8proc objconv
1515
# CMake libs: libgit2
1616
#
17-
# downloaded from git: llvm-svn, uv, libopenlibm, mojibake, openspecfun
17+
# downloaded from git: llvm-svn, uv, libopenlibm, utf8proc, openspecfun
1818
#
1919
# there are rules in this file with the . replaced by a %
2020
# this is some magic Makefile trick that tells make
@@ -150,8 +150,8 @@ ifeq ($(USE_SYSTEM_SUITESPARSE), 0)
150150
STAGE2_DEPS += suitesparse
151151
endif
152152

153-
ifeq ($(USE_SYSTEM_MOJIBAKE), 0)
154-
STAGE2_DEPS += mojibake
153+
ifeq ($(USE_SYSTEM_UTF8PROC), 0)
154+
STAGE2_DEPS += utf8proc
155155
endif
156156

157157
# Only compile standalone LAPACK if we are not using OpenBLAS.
@@ -183,7 +183,7 @@ install: $(addprefix install-, $(DEP_LIBS))
183183
cleanall: $(addprefix clean-, $(DEP_LIBS))
184184
distcleanall: $(addprefix distclean-, $(DEP_LIBS))
185185
rm -rf $(build_prefix)
186-
getall: get-llvm get-uv get-pcre get-openlibm get-openspecfun get-dsfmt get-Rmath-julia get-openblas get-lapack get-fftw get-suitesparse get-arpack get-unwind get-osxunwind get-gmp get-mpfr get-patchelf get-mojibake get-virtualenv get-objconv get-libgit2
186+
getall: get-llvm get-uv get-pcre get-openlibm get-openspecfun get-dsfmt get-Rmath-julia get-openblas get-lapack get-fftw get-suitesparse get-arpack get-unwind get-osxunwind get-gmp get-mpfr get-patchelf get-utf8proc get-virtualenv get-objconv get-libgit2
187187

188188
## PATHS ##
189189
# sort is used to remove potential duplicates
@@ -1344,47 +1344,47 @@ compile-fftw-double: $(FFTW_DOUBLE_OBJ_TARGET)
13441344
check-fftw-double: fftw-$(FFTW_VER)-double/checked
13451345
install-fftw-double: $(FFTW_DOUBLE_OBJ_TARGET)
13461346

1347-
## MOJIBAKE ##
1347+
## UTF8PROC ##
13481348

1349-
MOJIBAKE_SRC_TARGET = libmojibake/libmojibake.a
1350-
MOJIBAKE_OBJ_LIB = $(build_libdir)/libmojibake.a
1351-
MOJIBAKE_OBJ_HEADER = $(build_includedir)/mojibake.h
1352-
MOJIBAKE_OBJ_TARGET = $(MOJIBAKE_OBJ_LIB) $(MOJIBAKE_OBJ_HEADER)
1349+
UTF8PROC_SRC_TARGET = utf8proc/libutf8proc.a
1350+
UTF8PROC_OBJ_LIB = $(build_libdir)/libutf8proc.a
1351+
UTF8PROC_OBJ_HEADER = $(build_includedir)/utf8proc.h
1352+
UTF8PROC_OBJ_TARGET = $(UTF8PROC_OBJ_LIB) $(UTF8PROC_OBJ_HEADER)
13531353

13541354

1355-
libmojibake/Makefile:
1355+
utf8proc/Makefile:
13561356
(cd .. && git submodule init && git submodule update)
1357-
ifeq (exists, $(shell [ -d libmojibake/.git ] && echo exists ))
1358-
$(MOJIBAKE_SRC_TARGET): libmojibake/.git/HEAD
1357+
ifeq (exists, $(shell [ -d utf8proc/.git ] && echo exists ))
1358+
$(UTF8PROC_SRC_TARGET): utf8proc/.git/HEAD
13591359
endif
1360-
ifeq (exists, $(shell [ -d $(JULIAHOME)/.git/modules/deps/libmojibake ] && echo exists ))
1361-
$(MOJIBAKE_SRC_TARGET): $(JULIAHOME)/.git/modules/deps/libmojibake/HEAD
1360+
ifeq (exists, $(shell [ -d $(JULIAHOME)/.git/modules/deps/utf8proc ] && echo exists ))
1361+
$(UTF8PROC_SRC_TARGET): $(JULIAHOME)/.git/modules/deps/utf8proc/HEAD
13621362
endif
1363-
$(MOJIBAKE_SRC_TARGET): libmojibake/Makefile
1364-
$(MAKE) -C libmojibake cc="$(CC) -O2 -std=c99 $(fPIC) -DMOJIBAKE_EXPORTS" AR="$(AR)" libmojibake.a
1363+
$(UTF8PROC_SRC_TARGET): utf8proc/Makefile
1364+
$(MAKE) -C utf8proc cc="$(CC) -O2 -std=c99 $(fPIC) -DUTF8PROC_EXPORTS" AR="$(AR)" libutf8proc.a
13651365
touch -c $@
1366-
libmojibake/checked: $(MOJIBAKE_SRC_TARGET)
1366+
utf8proc/checked: $(UTF8PROC_SRC_TARGET)
13671367
ifeq ($(OS),$(BUILD_OS))
1368-
-$(MAKE) -C libmojibake check
1368+
-$(MAKE) -C utf8proc check
13691369
endif
13701370
echo 1 > $@
13711371

1372-
$(MOJIBAKE_OBJ_LIB): $(MOJIBAKE_SRC_TARGET)
1372+
$(UTF8PROC_OBJ_LIB): $(UTF8PROC_SRC_TARGET)
13731373
cp -f $< $@
13741374

1375-
$(MOJIBAKE_OBJ_HEADER): libmojibake/Makefile
1376-
cp -f libmojibake/mojibake.h $@
1375+
$(UTF8PROC_OBJ_HEADER): utf8proc/Makefile
1376+
cp -f utf8proc/utf8proc.h $@
13771377

1378-
clean-mojibake:
1379-
-$(MAKE) -C libmojibake clean
1380-
-rm -rf $(build_libdir)/libmojibake.a $(build_includedir)/mojibake.h
1381-
distclean-mojibake: clean-mojibake
1378+
clean-utf8proc:
1379+
-$(MAKE) -C utf8proc clean
1380+
-rm -rf $(build_libdir)/libutf8proc.a $(build_includedir)/utf8proc.h
1381+
distclean-utf8proc: clean-utf8proc
13821382

1383-
get-mojibake: libmojibake/Makefile
1384-
configure-mojibake: get-mojibake
1385-
compile-mojibake: $(MOJIBAKE_SRC_TARGET)
1386-
check-mojibake: libmojibake/checked
1387-
install-mojibake: $(MOJIBAKE_OBJ_TARGET)
1383+
get-utf8proc: utf8proc/Makefile
1384+
configure-utf8proc: get-utf8proc
1385+
compile-utf8proc: $(UTF8PROC_SRC_TARGET)
1386+
check-utf8proc: utf8proc/checked
1387+
install-utf8proc: $(UTF8PROC_OBJ_TARGET)
13881388

13891389
## SUITESPARSE ##
13901390

deps/libmojibake

-1
This file was deleted.

deps/utf8proc

Submodule utf8proc added at e1fdad0

src/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ ifeq ($(USE_LLVM_SHLIB),1)
3030
LLVMLINK = $(call exec,$(LLVM_CONFIG) --ldflags) -lLLVM-$(call exec,$(LLVM_CONFIG) --version)
3131
endif
3232

33-
COMMON_LIBS = -L$(build_shlibdir) -L$(build_libdir) $(LIBUV) $(LIBMOJIBAKE) $(NO_WHOLE_ARCHIVE) $(LLVMLINK) $(OSLIBS)
33+
COMMON_LIBS = -L$(build_shlibdir) -L$(build_libdir) $(LIBUV) $(LIBUTF8PROC) $(NO_WHOLE_ARCHIVE) $(LLVMLINK) $(OSLIBS)
3434
DEBUG_LIBS = $(WHOLE_ARCHIVE) $(BUILDDIR)/flisp/libflisp-debug.a $(WHOLE_ARCHIVE) $(BUILDDIR)/support/libsupport-debug.a $(COMMON_LIBS)
3535
RELEASE_LIBS = $(WHOLE_ARCHIVE) $(BUILDDIR)/flisp/libflisp.a $(WHOLE_ARCHIVE) $(BUILDDIR)/support/libsupport.a $(COMMON_LIBS)
3636

src/flisp/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ HEADERS = $(wildcard *.h) $(LIBUV_INC)/uv.h
2222
OBJS = $(SRCS:%.c=$(BUILDDIR)/%.o)
2323
DOBJS = $(SRCS:%.c=$(BUILDDIR)/%.dbg.obj)
2424
LLTDIR = ../support
25-
LLT = $(BUILDDIR)/$(LLTDIR)/libsupport.a $(LIBUV) $(LIBMOJIBAKE)
25+
LLT = $(BUILDDIR)/$(LLTDIR)/libsupport.a $(LIBUV) $(LIBUTF8PROC)
2626

2727
FLAGS = -I$(LLTDIR) $(CFLAGS) $(HFILEDIRS:%=-I%) \
2828
-I$(LIBUV_INC) -I$(build_includedir) $(LIBDIRS:%=-L%) \
29-
-DLIBRARY_EXPORTS -DMOJIBAKE_EXPORTS
29+
-DLIBRARY_EXPORTS -DUTF8PROC_EXPORT
3030
ifneq ($(USEMSVC), 1)
3131
FLAGS += -Wall -Wno-strict-aliasing -DUSE_COMPUTED_GOTO -fvisibility=hidden
3232
endif

src/flisp/Windows.mk

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ OBJECTS = \
2929
dirname.obj
3030

3131
LIBUV = $(MAKEDIR)\..\..\deps\libuv\libuv.lib
32-
LIBMOJIBAKE = $(MAKEDIR)\..\..\deps\libmojibake\libmojibake.lib
32+
LIBUTF8PROC = $(MAKEDIR)\..\..\deps\libutf8proc\libutf8proc.lib
3333
LIBSUPPORT = $(MAKEDIR)\..\support\libsupport.lib
3434

35-
INCLUDE = $(INCLUDE);$(MAKEDIR)\..\..\deps\libuv\include;$(MAKEDIR)\..\..\deps\libmojibake;$(MAKEDIR)\..\support
35+
INCLUDE = $(INCLUDE);$(MAKEDIR)\..\..\deps\libuv\include;$(MAKEDIR)\..\..\deps\libutf8proc;$(MAKEDIR)\..\support
3636

3737
CFLAGS = $(CFLAGS) /Qstd=c99 -D_CRT_SECURE_NO_WARNINGS -DLIBRARY_EXPORTS
3838
LFLAGS = $(LFLAGS) kernel32.lib ws2_32.lib psapi.lib advapi32.lib iphlpapi.lib
3939

4040
default: $(NAME).exe
4141

42-
$(NAME).exe: lib$(NAME).lib flmain.obj $(LIBSUPPORT) $(LIBUV) $(LIBMOJIBAKE)
42+
$(NAME).exe: lib$(NAME).lib flmain.obj $(LIBSUPPORT) $(LIBUV) $(LIBUTF8PROC)
4343
$(LINK) $(LFLAGS) /OUT:$(NAME).exe /PDB:$(NAME).pdb /MAP $**
4444

4545
$(LIBSUPPORT):
@@ -48,8 +48,8 @@ $(LIBSUPPORT):
4848
$(LIBUV):
4949
PUSHD $(MAKEDIR)\..\..\deps\libuv && $(MAKE) /NOLOGO /F Windows.mk && POPD
5050

51-
$(LIBMOJIBAKE):
52-
PUSHD $(MAKEDIR)\..\..\deps\libmojibake && cl -nologo /c utf8proc.c && $(AR) /OUT:libmojibake.lib utf8proc.obj && POPD
51+
$(LIBUTF8PROC):
52+
PUSHD $(MAKEDIR)\..\..\deps\libutf8proc && cl -nologo /c utf8proc.c && $(AR) /OUT:libutf8proc.lib utf8proc.obj && POPD
5353

5454
lib$(NAME).lib: $(OBJECTS)
5555
$(AR) /OUT:lib$(NAME).lib $**

src/flisp/julia_extensions.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
#include <string.h>
44
#include <assert.h>
55
#include "flisp.h"
6-
#include "mojibake.h"
6+
7+
#undef DLLEXPORT /* avoid conflicting definition */
8+
#include "utf8proc.h"
79

810
#ifdef __cplusplus
911
extern "C" {

src/flisp/string.c

+5-7
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@
1414
#include <errno.h>
1515

1616
#include "flisp.h"
17+
1718
#if !defined(_OS_WINDOWS_)
1819
#include <sys/time.h>
1920
#endif /* !_OS_WINDOWS_ */
2021

22+
#undef DLLEXPORT /* avoid conflicting definition */
23+
#include "utf8proc.h"
24+
2125
#ifdef __cplusplus
2226
extern "C" {
2327
#endif
@@ -53,19 +57,13 @@ value_t fl_string_count(value_t *args, u_int32_t nargs)
5357
return size_wrap(u8_charnum(str+start, stop-start));
5458
}
5559

56-
#if defined(_OS_WINDOWS_)
57-
extern int wcwidth(uint32_t c);
58-
#elif defined(_OS_LINUX_)
59-
extern int wcwidth(wchar_t c);
60-
#endif
61-
6260
value_t fl_string_width(value_t *args, u_int32_t nargs)
6361
{
6462
argcount("string.width", nargs, 1);
6563
if (iscprim(args[0])) {
6664
cprim_t *cp = (cprim_t*)ptr(args[0]);
6765
if (cp_class(cp) == wchartype) {
68-
int w = wcwidth(*(uint32_t*)cp_data(cp));
66+
int w = utf8proc_charwidth(*(uint32_t*)cp_data(cp));
6967
if (w < 0)
7068
return FL_F;
7169
return fixnum(w);

src/julia.expmap

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
rl_clear_input;
3030
save_arg_area_loc;
3131
u8_*;
32-
wcwidth;
3332
uv_*;
3433
add_library_mapping;
3534
utf8proc_*;

src/support/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ SRCS = hashing timefuncs ptrhash operators \
1111
utf8 ios htable bitvector \
1212
int2str libsupportinit arraylist strtod
1313
ifeq ($(OS),WINNT)
14-
SRCS += asprintf wcwidth
14+
SRCS += asprintf
1515
ifeq ($(ARCH),i686)
1616
SRCS += _setjmp.win32 _longjmp.win32
1717
else ifeq ($(ARCH),i386)
@@ -26,7 +26,7 @@ HEADERS = $(wildcard *.h) $(LIBUV_INC)/uv.h
2626
OBJS = $(SRCS:%=$(BUILDDIR)/%.o)
2727
DOBJS = $(SRCS:%=$(BUILDDIR)/%.dbg.obj)
2828

29-
FLAGS = $(CFLAGS) $(HFILEDIRS:%=-I%) -I$(LIBUV_INC) -DLIBRARY_EXPORTS
29+
FLAGS = $(CFLAGS) $(HFILEDIRS:%=-I%) -I$(LIBUV_INC) -I$(UTF8PROC_INC) -DLIBRARY_EXPORTS -DUTF8PROC_EXPORT
3030
ifneq ($(USEMSVC), 1)
3131
FLAGS += -Wall -Wno-strict-aliasing -fvisibility=hidden
3232
endif

src/support/Windows.mk

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ OBJECTS = \
3434
int2str.obj \
3535
libsupportinit.obj \
3636
arraylist.obj \
37-
asprintf.obj \
38-
wcwidth.obj
37+
asprintf.obj
3938

4039
INCLUDE = $(INCLUDE);$(MAKEDIR)\..\..\deps\libuv\include
4140
CFLAGS = $(CFLAGS) -D_CRT_SECURE_NO_WARNINGS -DLIBRARY_EXPORTS

src/support/utf8.c

+4-9
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434

3535
#include "utf8.h"
3636

37+
#undef DLLEXPORT /* avoid conflicting definition */
38+
#include "utf8proc.h"
39+
3740
#ifdef __cplusplus
3841
extern "C" {
3942
#endif
@@ -261,17 +264,10 @@ size_t u8_strlen(const char *s)
261264
return count;
262265
}
263266

264-
#if defined(_OS_WINDOWS_)
265-
extern int wcwidth(uint32_t ch);
266-
#elif defined(_OS_LINUX_)
267-
extern int wcwidth(wchar_t ch);
268-
#endif
269-
270267
size_t u8_strwidth(const char *s)
271268
{
272269
uint32_t ch;
273270
size_t nb, tot=0;
274-
int w;
275271
signed char sc;
276272

277273
while ((sc = (signed char)*s) != 0) {
@@ -293,8 +289,7 @@ size_t u8_strwidth(const char *s)
293289
case 0: ch += (unsigned char)*s++;
294290
}
295291
ch -= offsetsFromUTF8[nb];
296-
w = wcwidth(ch); // might return -1
297-
if (w > 0) tot += w;
292+
tot += utf8proc_charwidth(ch);
298293
}
299294
}
300295
return tot;

0 commit comments

Comments
 (0)