--- gforth/utf-8.fs 2005/12/31 15:46:10 1.18 +++ gforth/utf-8.fs 2006/02/20 08:22:28 1.22 @@ -128,6 +128,15 @@ $80 Value max-single-byte nip nip over - then ; +[IFUNDEF] wcwidth + : wcwidth abort ; +[THEN] + +: u8width ( xcaddr u -- n ) + 0 rot rot over + swap ?DO + I xc@+ swap >r wcwidth + + r> I - +LOOP ; + : set-encoding-utf-8 ( -- ) ['] u8emit is xemit ['] u8key is xkey @@ -139,6 +148,9 @@ $80 Value max-single-byte ['] u8!+? is xc!+? ['] u8@+ is xc@+ ['] u8len is xc-size +[ [IFDEF] x-width ] + ['] u8width is x-width +[ [THEN] ] ['] -u8trailing-garbage is -trailing-garbage ;