--- gforth/utf-8.fs 2009/12/31 15:32:35 1.40 +++ gforth/utf-8.fs 2010/12/31 18:09:02 1.42 @@ -1,6 +1,6 @@ \ UTF-8 handling 12dec04py -\ Copyright (C) 2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc. +\ Copyright (C) 2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc. \ This file is part of Gforth. @@ -273,15 +273,17 @@ here wc-table - Constant #wc-table \ inefficient table walk: -: wcwidth ( xc -- n ) +: xc-width ( xc -- n ) wc-table #wc-table over + swap ?DO dup I 2@ within IF I 2 cells + @ UNLOOP EXIT THEN 3 cells +LOOP 1 ; +[ELSE] + ' wcwidth Alias xc-width [THEN] : u8width ( xcaddr u -- n ) 0 rot rot over + swap ?DO - I xc@+ swap >r wcwidth + + I xc@+ swap >r xc-width + r> I - +LOOP ; : set-encoding-utf-8 ( -- )