Changeset 1211


Ignore:
Timestamp:
Oct 20, 2006, 6:17:12 PM (13 years ago)
Author:
Sam Hocevar
Message:
  • Implemented cucul_utf32_is_fullwidth().
Location:
libcaca/trunk/cucul
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/cucul/charset.c

    r982 r1211  
    237237}
    238238
     239/** \brief Tell whether a UTF-32 character is fullwidth.
     240 *
     241 *  This function returns 1 if the given UTF-32 character should be
     242 *  printed at twice the normal width (fullwidth), or 0 if it is a
     243 *  standard-width character or if the library does not know.
     244 *
     245 *  This function never fails.
     246 *
     247 *  \param ch The UTF-32 character.
     248 *  \return 1 if the character is fullwidth, 0 otherwise.
     249 */
     250int cucul_utf32_is_fullwidth(unsigned long int ch)
     251{
     252    if(ch < 0x2e80) /* Standard stuff */
     253        return 0;
     254    if(ch < 0xa700) /* Japanese, Korean, CJK, Yi... */
     255        return 1;
     256    if(ch < 0xac00) /* Modified Tone Letters, Syloti Nagri */
     257        return 0;
     258    if(ch < 0xd800) /* Hangul Syllables */
     259        return 1;
     260    if(ch < 0xf900) /* Misc crap */
     261        return 0;
     262    if(ch < 0xfb00) /* More CJK */
     263        return 1;
     264    if(ch < 0xfe20) /* Misc crap */
     265        return 0;
     266    if(ch < 0xfe70) /* More CJK */
     267        return 1;
     268    if(ch < 0xff00) /* Misc crap */
     269        return 0;
     270    if(ch < 0xff61) /* Fullwidth forms */
     271        return 1;
     272    if(ch < 0xffe0) /* Halfwidth forms */
     273        return 0;
     274    if(ch < 0xffe8) /* More fullwidth forms */
     275        return 1;
     276    if(ch < 0x20000) /* Misc crap */
     277        return 0;
     278    if(ch < 0xe0000) /* More CJK */
     279        return 1;
     280    return 0;
     281}
     282
    239283/*
    240284 * XXX: The following functions are local.
  • libcaca/trunk/cucul/cucul.h

    r1092 r1211  
    133133extern unsigned char cucul_utf32_to_cp437(unsigned long int);
    134134extern unsigned long int cucul_cp437_to_utf32(unsigned char);
     135extern int cucul_utf32_is_fullwidth(unsigned long int);
    135136/*  @} */
    136137
Note: See TracChangeset for help on using the changeset viewer.