changed PUT_BYTE_IN_HEX()

This commit is contained in:
hyung-hwan 2019-03-19 13:58:26 +00:00
parent d859fe00d0
commit 6eed4425ec

View File

@ -91,9 +91,9 @@
} \ } \
} while (0) } while (0)
#define PUT_BYTE_IN_HEX(byte) do { \ #define PUT_BYTE_IN_HEX(byte,extra_flags) do { \
mio_bch_t __xbuf[3]; \ mio_bch_t __xbuf[3]; \
mio_byte_to_bcstr (byte, __xbuf, MIO_COUNTOF(__xbuf), (16 | (ch == 'w'? MIO_BYTE_TO_BCSTR_LOWERCASE: 0)), '0'); \ mio_byte_to_bcstr ((byte), __xbuf, MIO_COUNTOF(__xbuf), (16 | (extra_flags)), '0'); \
PUT_OOCH(__xbuf[0], 1); \ PUT_OOCH(__xbuf[0], 1); \
PUT_OOCH(__xbuf[1], 1); \ PUT_OOCH(__xbuf[1], 1); \
} while (0) } while (0)
@ -741,20 +741,22 @@ static int fmtoutv (mio_t* mio, const fmtchar_t* fmt, mio_fmtout_data_t* data, v
else if (!(lm_flag & LF_L) && *usp <= 0xFFFF) else if (!(lm_flag & LF_L) && *usp <= 0xFFFF)
{ {
mio_uint16_t u16 = *usp; mio_uint16_t u16 = *usp;
int extra_flags = ((ch) == 'w'? MIO_BYTE_TO_BCSTR_LOWERCASE: 0);
PUT_OOCH('\\', 1); PUT_OOCH('\\', 1);
PUT_OOCH('u', 1); PUT_OOCH('u', 1);
PUT_BYTE_IN_HEX((u16 >> 8) & 0xFF); PUT_BYTE_IN_HEX((u16 >> 8) & 0xFF, extra_flags);
PUT_BYTE_IN_HEX(u16 & 0xFF); PUT_BYTE_IN_HEX(u16 & 0xFF, extra_flags);
} }
else else
{ {
mio_uint32_t u32 = *usp; mio_uint32_t u32 = *usp;
int extra_flags = ((ch) == 'w'? MIO_BYTE_TO_BCSTR_LOWERCASE: 0);
PUT_OOCH('\\', 1); PUT_OOCH('\\', 1);
PUT_OOCH('U', 1); PUT_OOCH('U', 1);
PUT_BYTE_IN_HEX((u32 >> 24) & 0xFF); PUT_BYTE_IN_HEX((u32 >> 24) & 0xFF, extra_flags);
PUT_BYTE_IN_HEX((u32 >> 16) & 0xFF); PUT_BYTE_IN_HEX((u32 >> 16) & 0xFF, extra_flags);
PUT_BYTE_IN_HEX((u32 >> 8) & 0xFF); PUT_BYTE_IN_HEX((u32 >> 8) & 0xFF, extra_flags);
PUT_BYTE_IN_HEX(u32 & 0xFF); PUT_BYTE_IN_HEX(u32 & 0xFF, extra_flags);
} }
usp++; usp++;
} }