From 93ffbc0d552a3ea855b9bcc7e05f5c9a681fd713 Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Tue, 19 Mar 2019 07:52:09 +0000 Subject: [PATCH] changed the way to put byte in hex --- moo/lib/fmtoutv.h | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/moo/lib/fmtoutv.h b/moo/lib/fmtoutv.h index a3aace0..86b641c 100644 --- a/moo/lib/fmtoutv.h +++ b/moo/lib/fmtoutv.h @@ -739,34 +739,20 @@ static int fmtoutv (moo_t* moo, const fmtchar_t* fmt, moo_fmtout_data_t* data, v else if (!(lm_flag & LF_L) && *usp <= 0xFFFF) { moo_uint16_t u16 = *usp; - moo_uint8_t* bsp = (moo_uint8_t*)&u16; PUT_OOCH('\\', 1); PUT_OOCH('u', 1); - #if defined(MOO_ENDIAN_BIG) - PUT_BYTE_IN_HEX(bsp[0]); - PUT_BYTE_IN_HEX(bsp[1]); - #else - PUT_BYTE_IN_HEX(bsp[1]); - PUT_BYTE_IN_HEX(bsp[0]); - #endif + PUT_BYTE_IN_HEX((u16 >> 8) & 0xFF); + PUT_BYTE_IN_HEX(u16 & 0xFF); } else { moo_uint32_t u32 = *usp; - moo_uint8_t* bsp = (moo_uint8_t*)&u32; PUT_OOCH('\\', 1); PUT_OOCH('U', 1); - #if defined(MOO_ENDIAN_BIG) - PUT_BYTE_IN_HEX(bsp[0]); - PUT_BYTE_IN_HEX(bsp[1]); - PUT_BYTE_IN_HEX(bsp[2]); - PUT_BYTE_IN_HEX(bsp[3]); - #else - PUT_BYTE_IN_HEX(bsp[3]); - PUT_BYTE_IN_HEX(bsp[2]); - PUT_BYTE_IN_HEX(bsp[1]); - PUT_BYTE_IN_HEX(bsp[0]); - #endif + PUT_BYTE_IN_HEX((u32 >> 24) & 0xFF); + PUT_BYTE_IN_HEX((u32 >> 16) & 0xFF); + PUT_BYTE_IN_HEX((u32 >> 8) & 0xFF); + PUT_BYTE_IN_HEX(u32 & 0xFF); } usp++; }