pub fn fold(c: char) -> char {
let from = c as u32;
if from <= 0x2CFF {
let from = from as u16;
let high_byte = (from >> 8) as u8;
let low_byte = (from & 0xff) as u8;
let single_char: u16 = match high_byte {
0x00 => match low_byte {
x @ _ if 0x41 <= x && x <= 0x5a => from.wrapping_add(0x0020),
0xb5 => 0x03bc,
x @ _ if 0xc0 <= x && x <= 0xd6 => from.wrapping_add(0x0020),
x @ _ if 0xd8 <= x && x <= 0xde => from.wrapping_add(0x0020),
_ => from,
},
0x01 => match low_byte {
x @ _ if x <= 0x2e => from | 1,
x @ _ if 0x32 <= x && x <= 0x36 => from | 1,
x @ _ if 0x39 <= x && x <= 0x47 => (from + 1) & !1,
x @ _ if 0x4a <= x && x <= 0x76 => from | 1,
0x78 => 0x00ff,
x @ _ if 0x79 <= x && x <= 0x7d => (from + 1) & !1,
0x7f => 0x0073,
0x81 => 0x0253,
x @ _ if 0x82 <= x && x <= 0x84 => from | 1,
0x86 => 0x0254,
0x87 => 0x0188,
x @ _ if 0x89 <= x && x <= 0x8a => from.wrapping_add(0x00cd),
0x8b => 0x018c,
0x8e => 0x01dd,
0x8f => 0x0259,
0x90 => 0x025b,
0x91 => 0x0192,
0x93 => 0x0260,
0x94 => 0x0263,
0x96 => 0x0269,
0x97 => 0x0268,
0x98 => 0x0199,
0x9c => 0x026f,
0x9d => 0x0272,
0x9f => 0x0275,
x @ _ if 0xa0 <= x && x <= 0xa4 => from | 1,
0xa6 => 0x0280,
0xa7 => 0x01a8,
0xa9 => 0x0283,
0xac => 0x01ad,
0xae => 0x0288,
0xaf => 0x01b0,
x @ _ if 0xb1 <= x && x <= 0xb2 => from.wrapping_add(0x00d9),
x @ _ if 0xb3 <= x && x <= 0xb5 => (from + 1) & !1,
0xb7 => 0x0292,
0xb8 => 0x01b9,
0xbc => 0x01bd,
0xc4 => 0x01c6,
0xc5 => 0x01c6,
0xc7 => 0x01c9,
0xc8 => 0x01c9,
0xca => 0x01cc,
x @ _ if 0xcb <= x && x <= 0xdb => (from + 1) & !1,
x @ _ if 0xde <= x && x <= 0xee => from | 1,
0xf1 => 0x01f3,
x @ _ if 0xf2 <= x && x <= 0xf4 => from | 1,
0xf6 => 0x0195,
0xf7 => 0x01bf,
x @ _ if 0xf8 <= x => from | 1,
_ => from,
},
0x02 => match low_byte {
x @ _ if x <= 0x1e => from | 1,
0x20 => 0x019e,
x @ _ if 0x22 <= x && x <= 0x32 => from | 1,
0x3a => 0x2c65,
0x3b => 0x023c,
0x3d => 0x019a,
0x3e => 0x2c66,
0x41 => 0x0242,
0x43 => 0x0180,
0x44 => 0x0289,
0x45 => 0x028c,
x @ _ if 0x46 <= x && x <= 0x4e => from | 1,
_ => from,
},
0x03 => match low_byte {
0x45 => 0x03b9,
x @ _ if 0x70 <= x && x <= 0x72 => from | 1,
0x76 => 0x0377,
0x7f => 0x03f3,
0x86 => 0x03ac,
x @ _ if 0x88 <= x && x <= 0x8a => from.wrapping_add(0x0025),
0x8c => 0x03cc,
x @ _ if 0x8e <= x && x <= 0x8f => from.wrapping_add(0x003f),
x @ _ if 0x91 <= x && x <= 0xa1 => from.wrapping_add(0x0020),
x @ _ if 0xa3 <= x && x <= 0xab => from.wrapping_add(0x0020),
0xc2 => 0x03c3,
0xcf => 0x03d7,
0xd0 => 0x03b2,
0xd1 => 0x03b8,
0xd5 => 0x03c6,
0xd6 => 0x03c0,
x @ _ if 0xd8 <= x && x <= 0xee => from | 1,
0xf0 => 0x03ba,
0xf1 => 0x03c1,
0xf4 => 0x03b8,
0xf5 => 0x03b5,
0xf7 => 0x03f8,
0xf9 => 0x03f2,
0xfa => 0x03fb,
x @ _ if 0xfd <= x => from.wrapping_sub(0x0082),
_ => from,
},
0x04 => match low_byte {
x @ _ if x <= 0x0f => from.wrapping_add(0x0050),
x @ _ if 0x10 <= x && x <= 0x2f => from.wrapping_add(0x0020),
x @ _ if 0x60 <= x && x <= 0x80 => from | 1,
x @ _ if 0x8a <= x && x <= 0xbe => from | 1,
0xc0 => 0x04cf,
x @ _ if 0xc1 <= x && x <= 0xcd => (from + 1) & !1,
x @ _ if 0xd0 <= x => from | 1,
_ => from,
},
0x05 => match low_byte {
x @ _ if x <= 0x2e => from | 1,
x @ _ if 0x31 <= x && x <= 0x56 => from.wrapping_add(0x0030),
_ => from,
},
0x06 => from,
0x07 => from,
0x08 => from,
0x09 => from,
0x0a => from,
0x0b => from,
0x0c => from,
0x0d => from,
0x0e => from,
0x0f => from,
0x10 => match low_byte {
x @ _ if 0xa0 <= x && x <= 0xc5 => from.wrapping_add(0x1c60),
0xc7 => 0x2d27,
0xcd => 0x2d2d,
_ => from,
},
0x11 => from,
0x12 => from,
0x13 => match low_byte {
x @ _ if 0xf8 <= x && x <= 0xfd => from.wrapping_sub(0x0008),
_ => from,
},
0x14 => from,
0x15 => from,
0x16 => from,
0x17 => from,
0x18 => from,
0x19 => from,
0x1a => from,
0x1b => from,
0x1c => match low_byte {
0x80 => 0x0432,
0x81 => 0x0434,
0x82 => 0x043e,
x @ _ if 0x83 <= x && x <= 0x84 => from.wrapping_sub(0x1842),
0x85 => 0x0442,
0x86 => 0x044a,
0x87 => 0x0463,
0x88 => 0xa64b,
0x89 => 0x1c8a,
x @ _ if 0x90 <= x && x <= 0xba => from.wrapping_sub(0x0bc0),
x @ _ if 0xbd <= x && x <= 0xbf => from.wrapping_sub(0x0bc0),
_ => from,
},
0x1d => from,
0x1e => match low_byte {
x @ _ if x <= 0x94 => from | 1,
0x9b => 0x1e61,
x @ _ if 0xa0 <= x && x <= 0xfe => from | 1,
_ => from,
},
0x1f => match low_byte {
x @ _ if 0x08 <= x && x <= 0x0f => from.wrapping_sub(0x0008),
x @ _ if 0x18 <= x && x <= 0x1d => from.wrapping_sub(0x0008),
x @ _ if 0x28 <= x && x <= 0x2f => from.wrapping_sub(0x0008),
x @ _ if 0x38 <= x && x <= 0x3f => from.wrapping_sub(0x0008),
x @ _ if 0x48 <= x && x <= 0x4d => from.wrapping_sub(0x0008),
x @ _ if 0x59 <= x && x <= 0x5f => {
if (from & 1) == 1 {
from.wrapping_sub(0x0008)
} else {
from
}
}
x @ _ if 0x68 <= x && x <= 0x6f => from.wrapping_sub(0x0008),
x @ _ if 0xb8 <= x && x <= 0xb9 => from.wrapping_sub(0x0008),
x @ _ if 0xba <= x && x <= 0xbb => from.wrapping_sub(0x004a),
0xbe => 0x03b9,
x @ _ if 0xc8 <= x && x <= 0xcb => from.wrapping_sub(0x0056),
x @ _ if 0xd8 <= x && x <= 0xd9 => from.wrapping_sub(0x0008),
x @ _ if 0xda <= x && x <= 0xdb => from.wrapping_sub(0x0064),
x @ _ if 0xe8 <= x && x <= 0xe9 => from.wrapping_sub(0x0008),
x @ _ if 0xea <= x && x <= 0xeb => from.wrapping_sub(0x0070),
0xec => 0x1fe5,
x @ _ if 0xf8 <= x && x <= 0xf9 => from.wrapping_sub(0x0080),
x @ _ if 0xfa <= x && x <= 0xfb => from.wrapping_sub(0x007e),
_ => from,
},
0x20 => from,
0x21 => match low_byte {
0x26 => 0x03c9,
0x2a => 0x006b,
0x2b => 0x00e5,
0x32 => 0x214e,
x @ _ if 0x60 <= x && x <= 0x6f => from.wrapping_add(0x0010),
0x83 => 0x2184,
_ => from,
},
0x22 => from,
0x23 => from,
0x24 => match low_byte {
x @ _ if 0xb6 <= x && x <= 0xcf => from.wrapping_add(0x001a),
_ => from,
},
0x25 => from,
0x26 => from,
0x27 => from,
0x28 => from,
0x29 => from,
0x2a => from,
0x2b => from,
0x2c => match low_byte {
x @ _ if x <= 0x2f => from.wrapping_add(0x0030),
0x60 => 0x2c61,
0x62 => 0x026b,
0x63 => 0x1d7d,
0x64 => 0x027d,
x @ _ if 0x67 <= x && x <= 0x6b => (from + 1) & !1,
0x6d => 0x0251,
0x6e => 0x0271,
0x6f => 0x0250,
0x70 => 0x0252,
0x72 => 0x2c73,
0x75 => 0x2c76,
x @ _ if 0x7e <= x && x <= 0x7f => from.wrapping_sub(0x2a3f),
x @ _ if 0x80 <= x && x <= 0xe2 => from | 1,
x @ _ if 0xeb <= x && x <= 0xed => (from + 1) & !1,
0xf2 => 0x2cf3,
_ => from,
},
_ => from,
};
unsafe { char::from_u32_unchecked(single_char as u32) }
} else {
let single_char: u32 = match from {
x @ _ if 0xa640 <= x && x <= 0xa66c => from | 1,
x @ _ if 0xa680 <= x && x <= 0xa69a => from | 1,
x @ _ if 0xa722 <= x && x <= 0xa72e => from | 1,
x @ _ if 0xa732 <= x && x <= 0xa76e => from | 1,
x @ _ if 0xa779 <= x && x <= 0xa77b => (from + 1) & !1,
0xa77d => 0x1d79,
x @ _ if 0xa77e <= x && x <= 0xa786 => from | 1,
0xa78b => 0xa78c,
0xa78d => 0x0265,
x @ _ if 0xa790 <= x && x <= 0xa792 => from | 1,
x @ _ if 0xa796 <= x && x <= 0xa7a8 => from | 1,
0xa7aa => 0x0266,
0xa7ab => 0x025c,
0xa7ac => 0x0261,
0xa7ad => 0x026c,
0xa7ae => 0x026a,
0xa7b0 => 0x029e,
0xa7b1 => 0x0287,
0xa7b2 => 0x029d,
0xa7b3 => 0xab53,
x @ _ if 0xa7b4 <= x && x <= 0xa7c2 => from | 1,
0xa7c4 => 0xa794,
0xa7c5 => 0x0282,
0xa7c6 => 0x1d8e,
x @ _ if 0xa7c7 <= x && x <= 0xa7c9 => (from + 1) & !1,
0xa7cb => 0x0264,
0xa7cc => 0xa7cd,
0xa7d0 => 0xa7d1,
x @ _ if 0xa7d6 <= x && x <= 0xa7da => from | 1,
0xa7dc => 0x019b,
0xa7f5 => 0xa7f6,
x @ _ if 0xab70 <= x && x <= 0xabbf => from.wrapping_sub(0x97d0),
x @ _ if 0xff21 <= x && x <= 0xff3a => from.wrapping_add(0x0020),
x @ _ if 0x10400 <= x && x <= 0x10427 => from.wrapping_add(0x0028),
x @ _ if 0x104b0 <= x && x <= 0x104d3 => from.wrapping_add(0x0028),
x @ _ if 0x10570 <= x && x <= 0x1057a => from.wrapping_add(0x0027),
x @ _ if 0x1057c <= x && x <= 0x1058a => from.wrapping_add(0x0027),
x @ _ if 0x1058c <= x && x <= 0x10592 => from.wrapping_add(0x0027),
x @ _ if 0x10594 <= x && x <= 0x10595 => from.wrapping_add(0x0027),
x @ _ if 0x10c80 <= x && x <= 0x10cb2 => from.wrapping_add(0x0040),
x @ _ if 0x10d50 <= x && x <= 0x10d65 => from.wrapping_add(0x0020),
x @ _ if 0x118a0 <= x && x <= 0x118bf => from.wrapping_add(0x0020),
x @ _ if 0x16e40 <= x && x <= 0x16e5f => from.wrapping_add(0x0020),
x @ _ if 0x1e900 <= x && x <= 0x1e921 => from.wrapping_add(0x0022),
_ => from,
};
unsafe { char::from_u32_unchecked(single_char as u32) }
}
}