diff --git a/moo/lib/fmt.c b/moo/lib/fmt.c index d641237..c5651ff 100644 --- a/moo/lib/fmt.c +++ b/moo/lib/fmt.c @@ -2345,6 +2345,10 @@ static MOO_INLINE int format_stack_args (moo_fmtout_t* fmtout, moo_ooi_t nargs, break; } + #if !defined(MOO_OOCH_IS_UCH) + case 'w': /* the string object is not in the unicode encoding */ + case 'W': /* treat w/W like k/K */ + #endif case 'k': case 'K': { @@ -2397,7 +2401,13 @@ static MOO_INLINE int format_stack_args (moo_fmtout_t* fmtout, moo_ooi_t nargs, else { moo_bch_t xbuf[3]; - moo_byte_to_bcstr (*bsp, xbuf, MOO_COUNTOF(xbuf), (16 | (ch == 'k'? MOO_BYTE_TO_BCSTR_LOWERCASE: 0)), '0'); + int flagged_radix = 16; + #if defined(HCL_OOCH_IS_UCH) + if (ch == 'k') flagged_radix |= MOO_BYTE_TO_BCSTR_LOWERCASE; + #else + if (ch == 'k' || ch == 'w') flagged_radix |= MOO_BYTE_TO_BCSTR_LOWERCASE; + #endif + moo_byte_to_bcstr (*bsp, xbuf, MOO_COUNTOF(xbuf), flagged_radix, '0'); if (lm_flag & (LF_H | LF_L)) PUT_BCS (fmtout, "\\x", 2); PUT_BCS (fmtout, xbuf, 2); } @@ -2413,6 +2423,7 @@ static MOO_INLINE int format_stack_args (moo_fmtout_t* fmtout, moo_ooi_t nargs, break; } + #if defined(MOO_OOCH_IS_UCH) case 'w': case 'W': { @@ -2479,6 +2490,7 @@ static MOO_INLINE int format_stack_args (moo_fmtout_t* fmtout, moo_ooi_t nargs, if ((flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH (fmtout, padc, width); break; } + #endif case 'O': /* object - ignore precision, width, adjustment */ GET_NEXT_ARG_TO (moo, nargs, &arg_state, arg);