comparison common.h @ 780:29225fa79236 libavutil

id3v2: Add support for UTF-16 encoding. patch by Anton Khirnov, wyskas gmail com
author diego
date Wed, 23 Sep 2009 18:22:00 +0000
parents 8848af31706f
children fd7a78f003e7
comparison
equal deleted inserted replaced
779:a0b16768a2f0 780:29225fa79236
264 val= (val<<6) + tmp;\ 264 val= (val<<6) + tmp;\
265 }\ 265 }\
266 } 266 }
267 267
268 /*! 268 /*!
269 * \def GET_UTF16(val, GET_16BIT, ERROR)
270 * Converts a UTF-16 character (2 or 4 bytes) to its 32-bit UCS-4 encoded form
271 * \param val is the output and should be of type uint32_t. It holds the converted
272 * UCS-4 character and should be a left value.
273 * \param GET_16BIT gets two bytes of UTF-16 encoded data converted to native endianness.
274 * It can be a function or a statement whose return value or evaluated value is of type
275 * uint16_t. It will be executed up to 2 times.
276 * \param ERROR action that should be taken when an invalid UTF-16 surrogate is
277 * returned from GET_BYTE. It should be a statement that jumps out of the macro,
278 * like exit(), goto, return, break, or continue.
279 */
280 #define GET_UTF16(val, GET_16BIT, ERROR)\
281 val = GET_16BIT;\
282 {\
283 unsigned int hi = val - 0xD800;\
284 if (hi < 0x800) {\
285 val = GET_16BIT - 0xDC00;\
286 if (val > 0x3FFU || hi > 0x3FFU)\
287 ERROR\
288 val += (hi<<10) + 0x10000;\
289 }\
290 }\
291
292 /*!
269 * \def PUT_UTF8(val, tmp, PUT_BYTE) 293 * \def PUT_UTF8(val, tmp, PUT_BYTE)
270 * Converts a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long). 294 * Converts a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long).
271 * \param val is an input-only argument and should be of type uint32_t. It holds 295 * \param val is an input-only argument and should be of type uint32_t. It holds
272 * a UCS-4 encoded Unicode character that is to be converted to UTF-8. If 296 * a UCS-4 encoded Unicode character that is to be converted to UTF-8. If
273 * val is given as a function it is executed only once. 297 * val is given as a function it is executed only once.