--- gforth/utf-8.fs 2006/02/19 17:27:12 1.19 +++ gforth/utf-8.fs 2006/05/01 09:45:56 1.23 @@ -128,9 +128,13 @@ $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 + + I xc@+ swap >r wcwidth + r> I - +LOOP ; : set-encoding-utf-8 ( -- ) @@ -144,7 +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 ; @@ -156,6 +162,9 @@ $80 Value max-single-byte s" UTF-8" search nip nip IF set-encoding-utf-8 ELSE set-encoding-fixed-width THEN ; -' utf-8-cold INIT8 chained +:noname ( -- ) + defers 'cold + utf-8-cold +; is 'cold utf-8-cold