/*
DO NOT EDIT BY HAND!!!

This file is generated by
 contrib/shell_utils/make-casetable.pl UnicodeData.txt utf16_casetable.h utf16_case.c

UnicodeData.txt is got from
http://www.unicode.org/Public/UNIDATA/UnicodeData.txt
*/

#include <stdint.h>

#include <atalk/unicode.h>

#include "utf16_casetable.h"

/*******************************************************************
 Convert a wide character to upper case.
*******************************************************************/
ucs2_t toupper_w(ucs2_t val)
{
    if ( val <= 0x02BF)
        return upper_table_1[val];

    if ( val >= 0x0340 && val <= 0x05BF)
        return upper_table_2[val-0x0340];

    if ( val >= 0x10C0 && val <= 0x10FF)
        return upper_table_3[val-0x10C0];

    if ( val >= 0x13C0 && val <= 0x13FF)
        return upper_table_4[val-0x13C0];

    if ( val >= 0x1C80 && val <= 0x1CBF)
        return upper_table_5[val-0x1C80];

    if ( val >= 0x1D40 && val <= 0x1DBF)
        return upper_table_6[val-0x1D40];

    if ( val >= 0x1E00 && val <= 0x1FFF)
        return upper_table_7[val-0x1E00];

    if ( val >= 0x2140 && val <= 0x21BF)
        return upper_table_8[val-0x2140];

    if ( val >= 0x24C0 && val <= 0x24FF)
        return upper_table_9[val-0x24C0];

    if ( val >= 0x2C00 && val <= 0x2D3F)
        return upper_table_10[val-0x2C00];

    if ( val >= 0xA640 && val <= 0xA6BF)
        return upper_table_11[val-0xA640];

    if ( val >= 0xA700 && val <= 0xA7FF)
        return upper_table_12[val-0xA700];

    if ( val >= 0xAB40 && val <= 0xABBF)
        return upper_table_13[val-0xAB40];

    if ( val >= 0xFF40 && val <= 0xFF7F)
        return upper_table_14[val-0xFF40];

    return (val);
}

/*******************************************************************
 Convert a surrogate pair to upper case.
*******************************************************************/
uint32_t toupper_sp(uint32_t val)
{
    if ( val >= 0xD801DC00 && val <= 0xD801DC7F)
        return upper_table_sp_1[val-0xD801DC00];

    if ( val >= 0xD801DCC0 && val <= 0xD801DCFF)
        return upper_table_sp_2[val-0xD801DCC0];

    if ( val >= 0xD801DD80 && val <= 0xD801DDBF)
        return upper_table_sp_3[val-0xD801DD80];

    if ( val >= 0xD803DCC0 && val <= 0xD803DCFF)
        return upper_table_sp_4[val-0xD803DCC0];

    if ( val >= 0xD806DCC0 && val <= 0xD806DCFF)
        return upper_table_sp_5[val-0xD806DCC0];

    if ( val >= 0xD81BDE40 && val <= 0xD81BDE7F)
        return upper_table_sp_6[val-0xD81BDE40];

    if ( val >= 0xD83ADD00 && val <= 0xD83ADD7F)
        return upper_table_sp_7[val-0xD83ADD00];

    return (val);
}

/*******************************************************************
 Convert a wide character to lower case.
*******************************************************************/
ucs2_t tolower_w(ucs2_t val)
{
    if ( val <= 0x007F)
        return lower_table_1[val];

    if ( val >= 0x00C0 && val <= 0x027F)
        return lower_table_2[val-0x00C0];

    if ( val >= 0x0340 && val <= 0x057F)
        return lower_table_3[val-0x0340];

    if ( val >= 0x1080 && val <= 0x10FF)
        return lower_table_4[val-0x1080];

    if ( val >= 0x1380 && val <= 0x13FF)
        return lower_table_5[val-0x1380];

    if ( val >= 0x1C80 && val <= 0x1CBF)
        return lower_table_6[val-0x1C80];

    if ( val >= 0x1E00 && val <= 0x1FFF)
        return lower_table_7[val-0x1E00];

    if ( val >= 0x2100 && val <= 0x21BF)
        return lower_table_8[val-0x2100];

    if ( val >= 0x2480 && val <= 0x24FF)
        return lower_table_9[val-0x2480];

    if ( val >= 0x2C00 && val <= 0x2CFF)
        return lower_table_10[val-0x2C00];

    if ( val >= 0xA640 && val <= 0xA6BF)
        return lower_table_11[val-0xA640];

    if ( val >= 0xA700 && val <= 0xA7FF)
        return lower_table_12[val-0xA700];

    if ( val >= 0xFF00 && val <= 0xFF3F)
        return lower_table_13[val-0xFF00];

    return (val);
}

/*******************************************************************
 Convert a surrogate pair to lower case.
*******************************************************************/
uint32_t tolower_sp(uint32_t val)
{
    if ( val >= 0xD801DC00 && val <= 0xD801DC3F)
        return lower_table_sp_1[val-0xD801DC00];

    if ( val >= 0xD801DC80 && val <= 0xD801DCFF)
        return lower_table_sp_2[val-0xD801DC80];

    if ( val >= 0xD801DD40 && val <= 0xD801DD7F)
        return lower_table_sp_3[val-0xD801DD40];

    if ( val >= 0xD801DD40 && val <= 0xD801DDBF)
        return lower_table_sp_4[val-0xD801DD40];

    if ( val >= 0xD803DC80 && val <= 0xD803DCBF)
        return lower_table_sp_5[val-0xD803DC80];

    if ( val >= 0xD806DC80 && val <= 0xD806DCBF)
        return lower_table_sp_6[val-0xD806DC80];

    if ( val >= 0xD81BDE40 && val <= 0xD81BDE7F)
        return lower_table_sp_7[val-0xD81BDE40];

    if ( val >= 0xD83ADD00 && val <= 0xD83ADD3F)
        return lower_table_sp_8[val-0xD83ADD00];

    return (val);
}

/* EOF */
