From 0c8afacd4a0296f812a4044d4d82c5a4f8dd08eb Mon Sep 17 00:00:00 2001 From: Quantum Date: Mon, 26 Aug 2013 14:38:19 -0400 Subject: [PATCH] Added X-SAMPA support, a while ago. --- Makefile | 2 +- include/ConversionData.inc | 318 +++++++++++++++++++++++++++++++++++++ include/MainWindow.hpp | 4 +- src/MainLogic.cpp | 226 +++++++------------------- src/MainWindow.cpp | 13 +- 5 files changed, 390 insertions(+), 173 deletions(-) create mode 100644 include/ConversionData.inc diff --git a/Makefile b/Makefile index fc9478f..9e30296 100644 --- a/Makefile +++ b/Makefile @@ -50,7 +50,7 @@ $(SRCDIR)\Zalgo.cpp: $(INCDIR)\MainWindow.hpp $(SRCDIR)\PreviewWindow.cpp: $(INCDIR)\PreviewWindow.hpp $(SRCDIR)\Window.cpp: $(INCDIR)\Window.hpp $(SRCDIR)\NLSWrap.cpp: $(INCDIR)\NLSWrap.hpp -$(SRCDIR)\MainLogic.cpp: $(INCDIR)\MainWindow.hpp $(INCDIR)\NLSWrap.hpp +$(SRCDIR)\MainLogic.cpp: $(INCDIR)\MainWindow.hpp $(INCDIR)\NLSWrap.hpp $(INCDIR)\ConversionData.inc $(OUTDIR)\Zalgo.res: Zalgo.rc $(RC) $(RCFLAGS) /fo$@ $** diff --git a/include/ConversionData.inc b/include/ConversionData.inc new file mode 100644 index 0000000..5e2b982 --- /dev/null +++ b/include/ConversionData.inc @@ -0,0 +1,318 @@ +const wchar_t zalgo_up_[] = { + 0x030d, 0x030e, 0x0304, 0x0305, 0x033f, 0x0311, 0x0306, 0x0310, 0x0352, + 0x0357, 0x0351, 0x0307, 0x0308, 0x030a, 0x0342, 0x0343, 0x0344, 0x034a, + 0x034b, 0x034c, 0x0303, 0x0302, 0x030c, 0x0350, 0x0300, 0x0301, 0x030b, + 0x030f, 0x0312, 0x0313, 0x0314, 0x033d, 0x0309, 0x0363, 0x0364, 0x0365, + 0x0366, 0x0367, 0x0368, 0x0369, 0x036a, 0x036b, 0x036c, 0x036d, 0x036e, + 0x036f, 0x033e, 0x035b, 0x0346, 0x031a, 0 +}; + +const wchar_t zalgo_down_[] = { + 0x0316, 0x0317, 0x0318, 0x0319, 0x031c, 0x031d, 0x031e, 0x031f, 0x0320, + 0x0324, 0x0325, 0x0326, 0x0329, 0x032a, 0x032b, 0x032c, 0x032d, 0x032e, + 0x032f, 0x0330, 0x0331, 0x0332, 0x0333, 0x0339, 0x033a, 0x033b, 0x033c, + 0x0345, 0x0347, 0x0348, 0x0349, 0x034d, 0x034e, 0x0353, 0x0354, 0x0355, + 0x0356, 0x0359, 0x035a, 0x0323, 0 +}; + +const wchar_t zalgo_mid_[] = { + 0x0315, 0x031b, 0x0340, 0x0341, 0x0358, 0x0321, 0x0322, 0x0327, 0x0328, + 0x0334, 0x0335, 0x0336, 0x034f, 0x035c, 0x035d, 0x035e, 0x035f, 0x0360, + 0x0362, 0x0338, 0x0337, 0x0361, 0x0489, 0 +}; + +const std::pair latin_cyrillic_[] = { + std::make_pair(L"a", 0x0430), std::make_pair(L"b", 0x0431), + std::make_pair(L"c", 0x0446), std::make_pair(L"ch", 0x0447), + std::make_pair(L"d", 0x0434), std::make_pair(L"e", 0x0435), + std::make_pair(L"f", 0x0444), std::make_pair(L"g", 0x0433), + std::make_pair(L"gh", 0x0445), std::make_pair(L"h", 0x0445), + std::make_pair(L"i", 0x0438), std::make_pair(L"j", 0x0439), + std::make_pair(L"k", 0x043A), std::make_pair(L"kh", 0x0445), + std::make_pair(L"l", 0x043B), std::make_pair(L"m", 0x043C), + std::make_pair(L"n", 0x043D), std::make_pair(L"o", 0x043E), + std::make_pair(L"p", 0x043F), std::make_pair(L"q", 0x043A), + std::make_pair(L"r", 0x0440), std::make_pair(L"s", 0x0441), + std::make_pair(L"sh", 0x0448), std::make_pair(L"t", 0x0442), + std::make_pair(L"ts", 0x0446), std::make_pair(L"u", 0x0443), + std::make_pair(L"v", 0x0432), std::make_pair(L"w", 0x0432), + std::make_pair(L"x", 0x0449), std::make_pair(L"y", 0x044B), + std::make_pair(L"ya", 0x044F), std::make_pair(L"z", 0x0437), + std::make_pair(L"zh", 0x0436), + std::make_pair(L"A", 0x0410), std::make_pair(L"B", 0x0411), + std::make_pair(L"C", 0x0426), std::make_pair(L"D", 0x0414), + std::make_pair(L"E", 0x0415), std::make_pair(L"F", 0x0424), + std::make_pair(L"G", 0x0413), std::make_pair(L"H", 0x0425), + std::make_pair(L"I", 0x0418), std::make_pair(L"J", 0x0419), + std::make_pair(L"K", 0x041A), std::make_pair(L"L", 0x041B), + std::make_pair(L"M", 0x041C), std::make_pair(L"N", 0x041D), + std::make_pair(L"O", 0x041E), std::make_pair(L"P", 0x041F), + std::make_pair(L"Q", 0x041A), std::make_pair(L"R", 0x0420), + std::make_pair(L"S", 0x0421), std::make_pair(L"T", 0x0422), + std::make_pair(L"U", 0x0423), std::make_pair(L"V", 0x0412), + std::make_pair(L"W", 0x0412), std::make_pair(L"X", 0x0429), + std::make_pair(L"Y", 0x042B), std::make_pair(L"Z", 0x0417), + std::make_pair(L"CH", 0x0427), std::make_pair(L"GH", 0x0425), + std::make_pair(L"KH", 0x0425), std::make_pair(L"SH", 0x0428), + std::make_pair(L"TS", 0x0426), std::make_pair(L"YA", 0x042F), + std::make_pair(L"ZH", 0x0416), + std::make_pair(L"Ch", 0x0427), std::make_pair(L"Gh", 0x0425), + std::make_pair(L"Kh", 0x0425), std::make_pair(L"Sh", 0x0428), + std::make_pair(L"Ts", 0x0426), std::make_pair(L"Ya", 0x042F), + std::make_pair(L"Zh", 0x0416), +}; + +const std::pair to_latin_[] = { + std::make_pair(0x0430, L"a"), std::make_pair(0x0431, L"b"), + std::make_pair(0x0432, L"v"), std::make_pair(0x0433, L"g"), + std::make_pair(0x0434, L"d"), std::make_pair(0x0435, L"e"), + std::make_pair(0x0451, L"e"), std::make_pair(0x0436, L"zh"), + std::make_pair(0x0437, L"z"), std::make_pair(0x0438, L"i"), + std::make_pair(0x0439, L"j"), std::make_pair(0x043a, L"k"), + std::make_pair(0x043b, L"l"), std::make_pair(0x043c, L"m"), + std::make_pair(0x043d, L"n"), std::make_pair(0x043e, L"o"), + std::make_pair(0x043f, L"p"), std::make_pair(0x0440, L"r"), + std::make_pair(0x0441, L"s"), std::make_pair(0x0442, L"t"), + std::make_pair(0x0443, L"u"), std::make_pair(0x0444, L"f"), + std::make_pair(0x0445, L"h"), std::make_pair(0x0446, L"ts"), + std::make_pair(0x0447, L"ch"),std::make_pair(0x0448, L"sh"), + std::make_pair(0x044a, L"\""),std::make_pair(0x0449, L"x"), + std::make_pair(0x044b, L"y"), std::make_pair(0x044c, L"'"), + std::make_pair(0x044d, L"e"), std::make_pair(0x044e, L"yu"), + std::make_pair(0x044f, L"ya"),std::make_pair(0x0456, L"i"), + std::make_pair(0x0473, L"f"), std::make_pair(0x0463, L"ye"), + std::make_pair(0x0475, L"i"), std::make_pair(0x0455, L"dz"), + std::make_pair(0x046f, L"ks"),std::make_pair(0x0471, L"ps"), + std::make_pair(0x0461, L"o"), std::make_pair(0x046b, L"u"), + std::make_pair(0x0410, L"A"), std::make_pair(0x0411, L"B"), + std::make_pair(0x0412, L"V"), std::make_pair(0x0413, L"G"), + std::make_pair(0x0414, L"D"), std::make_pair(0x0415, L"E"), + std::make_pair(0x0401, L"E"), std::make_pair(0x0416, L"Zh"), + std::make_pair(0x0417, L"Z"), std::make_pair(0x0418, L"I"), + std::make_pair(0x0419, L"J"), std::make_pair(0x041a, L"K"), + std::make_pair(0x041b, L"L"), std::make_pair(0x041c, L"M"), + std::make_pair(0x041d, L"N"), std::make_pair(0x041e, L"O"), + std::make_pair(0x041f, L"P"), std::make_pair(0x0420, L"R"), + std::make_pair(0x0421, L"S"), std::make_pair(0x0422, L"T"), + std::make_pair(0x0423, L"U"), std::make_pair(0x0424, L"F"), + std::make_pair(0x0425, L"H"), std::make_pair(0x0426, L"Ts"), + std::make_pair(0x0427, L"Ch"),std::make_pair(0x0428, L"Sh"), + std::make_pair(0x042a, L"\""),std::make_pair(0x0429, L"X"), + std::make_pair(0x042b, L"Y"), std::make_pair(0x042c, L"'"), + std::make_pair(0x042d, L"E"), std::make_pair(0x042e, L"Yu"), + std::make_pair(0x042f, L"Ya"),std::make_pair(0x0406, L"I"), + std::make_pair(0x0472, L"F"), std::make_pair(0x0462, L"Ye"), + std::make_pair(0x0474, L"I"), std::make_pair(0x0405, L"Dz"), + std::make_pair(0x046e, L"Ks"),std::make_pair(0x0470, L"Ps"), + std::make_pair(0x0460, L"O"), std::make_pair(0x046a, L"U"), + std::make_pair(0x03b1, L"a"), std::make_pair(0x03b2, L"b"), + std::make_pair(0x03b3, L"g"), std::make_pair(0x03b4, L"d"), + std::make_pair(0x03b5, L"e"), std::make_pair(0x03b6, L"z"), + std::make_pair(0x03b7, L"e"), std::make_pair(0x03b8, L"th"), + std::make_pair(0x03b9, L"i"), std::make_pair(0x03ba, L"k"), + std::make_pair(0x03bb, L"l"), std::make_pair(0x03bc, L"m"), + std::make_pair(0x03bd, L"n"), std::make_pair(0x03be, L"x"), + std::make_pair(0x03bf, L"o"), std::make_pair(0x03c0, L"p"), + std::make_pair(0x03c1, L"r"), std::make_pair(0x03c3, L"s"), + std::make_pair(0x03c4, L"t"), std::make_pair(0x03c5, L"u"), + std::make_pair(0x03c6, L"f"), std::make_pair(0x03c7, L"h"), + std::make_pair(0x03c8, L"ps"),std::make_pair(0x03c9, L"o"), + std::make_pair(0x0391, L"A"), std::make_pair(0x0392, L"B"), + std::make_pair(0x0393, L"G"), std::make_pair(0x0394, L"D"), + std::make_pair(0x0395, L"E"), std::make_pair(0x0396, L"Z"), + std::make_pair(0x0397, L"E"), std::make_pair(0x0398, L"Th"), + std::make_pair(0x0399, L"I"), std::make_pair(0x039a, L"K"), + std::make_pair(0x039b, L"L"), std::make_pair(0x039c, L"M"), + std::make_pair(0x039d, L"N"), std::make_pair(0x039e, L"X"), + std::make_pair(0x039f, L"O"), std::make_pair(0x03a0, L"P"), + std::make_pair(0x03a1, L"R"), std::make_pair(0x03a3, L"S"), + std::make_pair(0x03a4, L"T"), std::make_pair(0x03a5, L"U"), + std::make_pair(0x03a6, L"F"), std::make_pair(0x03a7, L"H"), + std::make_pair(0x03a8, L"Ps"),std::make_pair(0x03a9, L"O"), + std::make_pair(0x03c2, L"s"), +}; + +const std::pair latin_greek_[] = { + std::make_pair(L"a", 0x03b1), std::make_pair(L"b", 0x03b2), + std::make_pair(L"c", 0x03c7), std::make_pair(L"d", 0x03b4), + std::make_pair(L"e", 0x03b5), std::make_pair(L"f", 0x03c6), + std::make_pair(L"g", 0x03b3), std::make_pair(L"h", 0x03c7), + std::make_pair(L"i", 0x03b9), std::make_pair(L"j", 0x03b7), + std::make_pair(L"k", 0x03ba), std::make_pair(L"l", 0x03bb), + std::make_pair(L"m", 0x03bc), std::make_pair(L"n", 0x03bd), + std::make_pair(L"o", 0x03bf), std::make_pair(L"p", 0x03c0), + std::make_pair(L"ps", 0x03c8),std::make_pair(L"q", 0x03ba), + std::make_pair(L"r", 0x03c1), std::make_pair(L"s", 0x03c3), + std::make_pair(L"t", 0x03c4), std::make_pair(L"th", 0x03b8), + std::make_pair(L"u", 0x03c5), std::make_pair(L"v", 0x03c6), + std::make_pair(L"w", 0x03c5), std::make_pair(L"x", 0x03be), + std::make_pair(L"y", 0x03c5), std::make_pair(L"z", 0x03b6), + std::make_pair(L"A", 0x0391), std::make_pair(L"B", 0x0392), + std::make_pair(L"C", 0x03a7), std::make_pair(L"D", 0x0394), + std::make_pair(L"E", 0x0395), std::make_pair(L"F", 0x03a6), + std::make_pair(L"G", 0x0393), std::make_pair(L"H", 0x03a7), + std::make_pair(L"I", 0x0399), std::make_pair(L"J", 0x0397), + std::make_pair(L"K", 0x039a), std::make_pair(L"L", 0x039b), + std::make_pair(L"M", 0x039c), std::make_pair(L"N", 0x039d), + std::make_pair(L"O", 0x039f), std::make_pair(L"P", 0x03a0), + std::make_pair(L"Ps", 0x03a8),std::make_pair(L"Q", 0x039a), + std::make_pair(L"R", 0x03a1), std::make_pair(L"S", 0x03a3), + std::make_pair(L"U", 0x03a5), std::make_pair(L"V", 0x03a6), + std::make_pair(L"W", 0x03a5), std::make_pair(L"X", 0x039e), + std::make_pair(L"Y", 0x03a5), std::make_pair(L"Z", 0x0396), + std::make_pair(L"T", 0x03a4), std::make_pair(L"Th", 0x0398), + std::make_pair(L"PS", 0x03a8),std::make_pair(L"TH", 0x0398), +}; + +const std::pair x_sampa_[] = { + std::make_pair(L"b_<" , 0x0253), + std::make_pair(L"d`" , 0x0256), + std::make_pair(L"d_<" , 0x0257), + std::make_pair(L"g" , 0x0261), + std::make_pair(L"g_<" , 0x0260), + std::make_pair(L"h\\" , 0x0266), + std::make_pair(L"j\\" , 0x029d), + std::make_pair(L"l`" , 0x026d), + std::make_pair(L"l\\" , 0x027a), + std::make_pair(L"n`" , 0x0273), + std::make_pair(L"p\\" , 0x0278), + std::make_pair(L"r`" , 0x027d), + std::make_pair(L"r\\" , 0x0279), + std::make_pair(L"r\\`" , 0x027b), + std::make_pair(L"s`" , 0x0282), + std::make_pair(L"s\\" , 0x0255), + std::make_pair(L"t`" , 0x0288), + std::make_pair(L"v\\" , 0x028b), + std::make_pair(L"x\\" , 0x0267), + std::make_pair(L"z`" , 0x0290), + std::make_pair(L"z\\" , 0x0291), + std::make_pair(L"A" , 0x0251), + std::make_pair(L"B" , 0x03b2), + std::make_pair(L"B\\" , 0x0299), + std::make_pair(L"C" , 0x00e7), + std::make_pair(L"D" , 0x00f0), + std::make_pair(L"E" , 0x025b), + std::make_pair(L"F" , 0x0271), + std::make_pair(L"G" , 0x0263), + std::make_pair(L"G\\" , 0x0262), + std::make_pair(L"G\\_<" , 0x029b), + std::make_pair(L"H" , 0x0265), + std::make_pair(L"H\\" , 0x029c), + std::make_pair(L"I" , 0x026a), + std::make_pair(L"I\\" , 0x1d7b), + std::make_pair(L"J" , 0x0272), + std::make_pair(L"J\\" , 0x025f), + std::make_pair(L"J\\_<" , 0x0284), + std::make_pair(L"K" , 0x026c), + std::make_pair(L"K\\" , 0x026e), + std::make_pair(L"L" , 0x028e), + std::make_pair(L"L\\" , 0x029f), + std::make_pair(L"M" , 0x026f), + std::make_pair(L"M\\" , 0x0270), + std::make_pair(L"N" , 0x014b), + std::make_pair(L"N\\" , 0x0274), + std::make_pair(L"O" , 0x0254), + std::make_pair(L"O\\" , 0x0298), + std::make_pair(L"P" , 0x028b), + std::make_pair(L"Q" , 0x0252), + std::make_pair(L"R" , 0x0281), + std::make_pair(L"R\\" , 0x0280), + std::make_pair(L"S" , 0x0283), + std::make_pair(L"T" , 0x03b8), + std::make_pair(L"U" , 0x028a), + std::make_pair(L"U\\" , 0x1d7f), + std::make_pair(L"V" , 0x028c), + std::make_pair(L"W" , 0x028d), + std::make_pair(L"X" , 0x03c7), + std::make_pair(L"X\\" , 0x0127), + std::make_pair(L"Y" , 0x028f), + std::make_pair(L"Z" , 0x0292), + std::make_pair(L"\"" , 0x02c8), + std::make_pair(L"%" , 0x02cc), + std::make_pair(L"'" , 0x02b2), + std::make_pair(L"_j" , 0x02b2), + std::make_pair(L":" , 0x02d0), + std::make_pair(L":\\" , 0x02d1), + std::make_pair(L"-" , 0x0000), + std::make_pair(L"@" , 0x0259), + std::make_pair(L"@\\" , 0x0258), + std::make_pair(L"{" , 0x00e6), + std::make_pair(L"}" , 0x0289), + std::make_pair(L"1" , 0x0268), + std::make_pair(L"2" , 0x00f8), + std::make_pair(L"3" , 0x025c), + std::make_pair(L"3\\" , 0x025e), + std::make_pair(L"4" , 0x027e), + std::make_pair(L"5" , 0x026b), + std::make_pair(L"6" , 0x0250), + std::make_pair(L"7" , 0x0264), + std::make_pair(L"8" , 0x0275), + std::make_pair(L"9" , 0x0153), + std::make_pair(L"&" , 0x0276), + std::make_pair(L"?" , 0x0294), + std::make_pair(L"?\\" , 0x0295), + std::make_pair(L"*" , 0x0000), + std::make_pair(L"/" , 0x0000), + std::make_pair(L"<" , 0x0000), + std::make_pair(L"<\\" , 0x02a2), + std::make_pair(L">" , 0x0000), + std::make_pair(L">\\" , 0x02a1), + std::make_pair(L"^" , 0xa71b), + std::make_pair(L"!" , 0xa71c), + std::make_pair(L"!\\" , 0x01c3), + std::make_pair(L"|\\" , 0x01c0), + std::make_pair(L"||" , 0x2016), + std::make_pair(L"|\\|\\", 0x01c1), + std::make_pair(L"=\\" , 0x01c2), + std::make_pair(L"-\\" , 0x203f), + std::make_pair(L"_\"" , 0x0308), + std::make_pair(L"_+" , 0x031f), + std::make_pair(L"_-" , 0x0320), + std::make_pair(L"_/" , 0x030c), + std::make_pair(L"_0" , 0x0325), + std::make_pair(L"_<" , 0x0000), + std::make_pair(L"=" , 0x0329), + std::make_pair(L"_=)" , 0x0329), + std::make_pair(L"_>" , 0x02bc), + std::make_pair(L"_?\\" , 0x02e4), + std::make_pair(L"_\\" , 0x0302), + std::make_pair(L"_^" , 0x032f), + std::make_pair(L"_}" , 0x031a), + std::make_pair(L"`" , 0x02de), + std::make_pair(L"~" , 0x0303), + std::make_pair(L"_~" , 0x0303), + std::make_pair(L"_A" , 0x0318), + std::make_pair(L"_a" , 0x033a), + std::make_pair(L"_B" , 0x030f), + std::make_pair(L"_B_L" , 0x1dc5), + std::make_pair(L"_c" , 0x031c), + std::make_pair(L"_d" , 0x032a), + std::make_pair(L"_e" , 0x0334), + std::make_pair(L"" , 0x2198), + std::make_pair(L"_F" , 0x0302), + std::make_pair(L"_G" , 0x02e0), + std::make_pair(L"_H" , 0x0301), + std::make_pair(L"_H_T" , 0x1dc4), + std::make_pair(L"_h" , 0x02b0), + std::make_pair(L"_k" , 0x0330), + std::make_pair(L"_L" , 0x0300), + std::make_pair(L"_l" , 0x02e1), + std::make_pair(L"_M" , 0x0304), + std::make_pair(L"_m" , 0x033b), + std::make_pair(L"_N" , 0x033c), + std::make_pair(L"_n" , 0x207f), + std::make_pair(L"_O" , 0x0339), + std::make_pair(L"_o" , 0x031e), + std::make_pair(L"_q" , 0x0319), + std::make_pair(L"" , 0x2197), + std::make_pair(L"_R" , 0x030c), + std::make_pair(L"_R_F" , 0x1dc8), + std::make_pair(L"_r" , 0x031d), + std::make_pair(L"_T" , 0x030b), + std::make_pair(L"_t" , 0x0324), + std::make_pair(L"_v" , 0x032c), + std::make_pair(L"_w" , 0x02b7), + std::make_pair(L"_X" , 0x0306), + std::make_pair(L"_x" , 0x033d), + std::make_pair(L"_" , 0x0361), +}; diff --git a/include/MainWindow.hpp b/include/MainWindow.hpp index ae11d30..09d28ac 100644 --- a/include/MainWindow.hpp +++ b/include/MainWindow.hpp @@ -26,6 +26,7 @@ #define ZALGO_LATIN 0xA554 #define ZALGO_CYRILLIC 0xA555 #define ZALGO_GREEK 0xA556 +#define ZALGO_XSAMPA 0xA557 class MainWindow : public Window { public: @@ -46,6 +47,7 @@ protected: void OnTextCyrillic(); void OnTextLatin(); void OnTextGreek(); + void OnTextXSAMPA(); HWND m_message; HWND m_goUp, m_goMiddle, m_goDown; @@ -53,7 +55,7 @@ protected: HWND m_messLevel, m_messUpDown; HWND m_mess, m_unmess, m_previewShow; HWND m_nfc, m_nfd; - HWND m_latin, m_cyrillic, m_greek; + HWND m_latin, m_cyrillic, m_greek, m_xsampa; MyDropTarget m_dropTarget; PreviewWindow *m_preview; private: diff --git a/src/MainLogic.cpp b/src/MainLogic.cpp index 4110d9f..10adaee 100644 --- a/src/MainLogic.cpp +++ b/src/MainLogic.cpp @@ -9,185 +9,20 @@ typedef std::basic_string wstring; -const wchar_t zalgo_up_[] = { - 0x030d, 0x030e, 0x0304, 0x0305, 0x033f, 0x0311, 0x0306, 0x0310, 0x0352, - 0x0357, 0x0351, 0x0307, 0x0308, 0x030a, 0x0342, 0x0343, 0x0344, 0x034a, - 0x034b, 0x034c, 0x0303, 0x0302, 0x030c, 0x0350, 0x0300, 0x0301, 0x030b, - 0x030f, 0x0312, 0x0313, 0x0314, 0x033d, 0x0309, 0x0363, 0x0364, 0x0365, - 0x0366, 0x0367, 0x0368, 0x0369, 0x036a, 0x036b, 0x036c, 0x036d, 0x036e, - 0x036f, 0x033e, 0x035b, 0x0346, 0x031a, 0 -}; - -const wchar_t zalgo_down_[] = { - 0x0316, 0x0317, 0x0318, 0x0319, 0x031c, 0x031d, 0x031e, 0x031f, 0x0320, - 0x0324, 0x0325, 0x0326, 0x0329, 0x032a, 0x032b, 0x032c, 0x032d, 0x032e, - 0x032f, 0x0330, 0x0331, 0x0332, 0x0333, 0x0339, 0x033a, 0x033b, 0x033c, - 0x0345, 0x0347, 0x0348, 0x0349, 0x034d, 0x034e, 0x0353, 0x0354, 0x0355, - 0x0356, 0x0359, 0x035a, 0x0323, 0 -}; - -const wchar_t zalgo_mid_[] = { - 0x0315, 0x031b, 0x0340, 0x0341, 0x0358, 0x0321, 0x0322, 0x0327, 0x0328, - 0x0334, 0x0335, 0x0336, 0x034f, 0x035c, 0x035d, 0x035e, 0x035f, 0x0360, - 0x0362, 0x0338, 0x0337, 0x0361, 0x0489, 0 -}; +#include const wstring zalgo_up = zalgo_up_; const wstring zalgo_down = zalgo_down_; const wstring zalgo_mid = zalgo_mid_; -const std::pair latin_cyrillic_[] = { - std::make_pair(L"a", 0x0430), std::make_pair(L"b", 0x0431), - std::make_pair(L"c", 0x0446), std::make_pair(L"ch", 0x0447), - std::make_pair(L"d", 0x0434), std::make_pair(L"e", 0x0435), - std::make_pair(L"f", 0x0444), std::make_pair(L"g", 0x0433), - std::make_pair(L"gh", 0x0445), std::make_pair(L"h", 0x0445), - std::make_pair(L"i", 0x0438), std::make_pair(L"j", 0x0439), - std::make_pair(L"k", 0x043A), std::make_pair(L"kh", 0x0445), - std::make_pair(L"l", 0x043B), std::make_pair(L"m", 0x043C), - std::make_pair(L"n", 0x043D), std::make_pair(L"o", 0x043E), - std::make_pair(L"p", 0x043F), std::make_pair(L"q", 0x043A), - std::make_pair(L"r", 0x0440), std::make_pair(L"s", 0x0441), - std::make_pair(L"sh", 0x0448), std::make_pair(L"t", 0x0442), - std::make_pair(L"ts", 0x0446), std::make_pair(L"u", 0x0443), - std::make_pair(L"v", 0x0432), std::make_pair(L"w", 0x0432), - std::make_pair(L"x", 0x0449), std::make_pair(L"y", 0x044B), - std::make_pair(L"ya", 0x044F), std::make_pair(L"z", 0x0437), - std::make_pair(L"zh", 0x0436), - std::make_pair(L"A", 0x0410), std::make_pair(L"B", 0x0411), - std::make_pair(L"C", 0x0426), std::make_pair(L"D", 0x0414), - std::make_pair(L"E", 0x0415), std::make_pair(L"F", 0x0424), - std::make_pair(L"G", 0x0413), std::make_pair(L"H", 0x0425), - std::make_pair(L"I", 0x0418), std::make_pair(L"J", 0x0419), - std::make_pair(L"K", 0x041A), std::make_pair(L"L", 0x041B), - std::make_pair(L"M", 0x041C), std::make_pair(L"N", 0x041D), - std::make_pair(L"O", 0x041E), std::make_pair(L"P", 0x041F), - std::make_pair(L"Q", 0x041A), std::make_pair(L"R", 0x0420), - std::make_pair(L"S", 0x0421), std::make_pair(L"T", 0x0422), - std::make_pair(L"U", 0x0423), std::make_pair(L"V", 0x0412), - std::make_pair(L"W", 0x0412), std::make_pair(L"X", 0x0429), - std::make_pair(L"Y", 0x042B), std::make_pair(L"Z", 0x0417), - std::make_pair(L"CH", 0x0427), std::make_pair(L"GH", 0x0425), - std::make_pair(L"KH", 0x0425), std::make_pair(L"SH", 0x0428), - std::make_pair(L"TS", 0x0426), std::make_pair(L"YA", 0x042F), - std::make_pair(L"ZH", 0x0416), - std::make_pair(L"Ch", 0x0427), std::make_pair(L"Gh", 0x0425), - std::make_pair(L"Kh", 0x0425), std::make_pair(L"Sh", 0x0428), - std::make_pair(L"Ts", 0x0426), std::make_pair(L"Ya", 0x042F), - std::make_pair(L"Zh", 0x0416), -}; - -const std::pair to_latin_[] = { - std::make_pair(0x0430, L"a"), std::make_pair(0x0431, L"b"), - std::make_pair(0x0432, L"v"), std::make_pair(0x0433, L"g"), - std::make_pair(0x0434, L"d"), std::make_pair(0x0435, L"e"), - std::make_pair(0x0451, L"e"), std::make_pair(0x0436, L"zh"), - std::make_pair(0x0437, L"z"), std::make_pair(0x0438, L"i"), - std::make_pair(0x0439, L"j"), std::make_pair(0x043a, L"k"), - std::make_pair(0x043b, L"l"), std::make_pair(0x043c, L"m"), - std::make_pair(0x043d, L"n"), std::make_pair(0x043e, L"o"), - std::make_pair(0x043f, L"p"), std::make_pair(0x0440, L"r"), - std::make_pair(0x0441, L"s"), std::make_pair(0x0442, L"t"), - std::make_pair(0x0443, L"u"), std::make_pair(0x0444, L"f"), - std::make_pair(0x0445, L"h"), std::make_pair(0x0446, L"ts"), - std::make_pair(0x0447, L"ch"),std::make_pair(0x0448, L"sh"), - std::make_pair(0x044a, L"\""),std::make_pair(0x0449, L"shch"), - std::make_pair(0x044b, L"y"), std::make_pair(0x044c, L"'"), - std::make_pair(0x044d, L"e"), std::make_pair(0x044e, L"yu"), - std::make_pair(0x044f, L"ya"),std::make_pair(0x0456, L"i"), - std::make_pair(0x0473, L"f"), std::make_pair(0x0463, L"ye"), - std::make_pair(0x0475, L"i"), std::make_pair(0x0455, L"dz"), - std::make_pair(0x046f, L"ks"),std::make_pair(0x0471, L"ps"), - std::make_pair(0x0461, L"o"), std::make_pair(0x046b, L"u"), - std::make_pair(0x0410, L"A"), std::make_pair(0x0411, L"B"), - std::make_pair(0x0412, L"V"), std::make_pair(0x0413, L"G"), - std::make_pair(0x0414, L"D"), std::make_pair(0x0415, L"E"), - std::make_pair(0x0401, L"E"), std::make_pair(0x0416, L"Zh"), - std::make_pair(0x0417, L"Z"), std::make_pair(0x0418, L"I"), - std::make_pair(0x0419, L"J"), std::make_pair(0x041a, L"K"), - std::make_pair(0x041b, L"L"), std::make_pair(0x041c, L"M"), - std::make_pair(0x041d, L"N"), std::make_pair(0x041e, L"O"), - std::make_pair(0x041f, L"P"), std::make_pair(0x0420, L"R"), - std::make_pair(0x0421, L"S"), std::make_pair(0x0422, L"T"), - std::make_pair(0x0423, L"U"), std::make_pair(0x0424, L"F"), - std::make_pair(0x0425, L"H"), std::make_pair(0x0426, L"Ts"), - std::make_pair(0x0427, L"Ch"),std::make_pair(0x0428, L"Sh"), - std::make_pair(0x042a, L"\""),std::make_pair(0x0429, L"Shch"), - std::make_pair(0x042b, L"Y"), std::make_pair(0x042c, L"'"), - std::make_pair(0x042d, L"E"), std::make_pair(0x042e, L"Yu"), - std::make_pair(0x042f, L"Ya"),std::make_pair(0x0406, L"I"), - std::make_pair(0x0472, L"F"), std::make_pair(0x0462, L"Ye"), - std::make_pair(0x0474, L"I"), std::make_pair(0x0405, L"Dz"), - std::make_pair(0x046e, L"Ks"),std::make_pair(0x0470, L"Ps"), - std::make_pair(0x0460, L"O"), std::make_pair(0x046a, L"U"), - std::make_pair(0x03b1, L"a"), std::make_pair(0x03b2, L"b"), - std::make_pair(0x03b3, L"g"), std::make_pair(0x03b4, L"d"), - std::make_pair(0x03b5, L"e"), std::make_pair(0x03b6, L"z"), - std::make_pair(0x03b7, L"e"), std::make_pair(0x03b8, L"th"), - std::make_pair(0x03b9, L"i"), std::make_pair(0x03ba, L"k"), - std::make_pair(0x03bb, L"l"), std::make_pair(0x03bc, L"m"), - std::make_pair(0x03bd, L"n"), std::make_pair(0x03be, L"x"), - std::make_pair(0x03bf, L"o"), std::make_pair(0x03c0, L"p"), - std::make_pair(0x03c1, L"r"), std::make_pair(0x03c3, L"s"), - std::make_pair(0x03c4, L"t"), std::make_pair(0x03c5, L"u"), - std::make_pair(0x03c6, L"f"), std::make_pair(0x03c7, L"ch"), - std::make_pair(0x03c8, L"ps"),std::make_pair(0x03c9, L"o"), - std::make_pair(0x0391, L"A"), std::make_pair(0x0392, L"B"), - std::make_pair(0x0393, L"G"), std::make_pair(0x0394, L"D"), - std::make_pair(0x0395, L"E"), std::make_pair(0x0396, L"Z"), - std::make_pair(0x0397, L"E"), std::make_pair(0x0398, L"Th"), - std::make_pair(0x0399, L"I"), std::make_pair(0x039a, L"K"), - std::make_pair(0x039b, L"L"), std::make_pair(0x039c, L"M"), - std::make_pair(0x039d, L"N"), std::make_pair(0x039e, L"X"), - std::make_pair(0x039f, L"O"), std::make_pair(0x03a0, L"P"), - std::make_pair(0x03a1, L"R"), std::make_pair(0x03a3, L"S"), - std::make_pair(0x03a4, L"T"), std::make_pair(0x03a5, L"U"), - std::make_pair(0x03a6, L"F"), std::make_pair(0x03a7, L"Ch"), - std::make_pair(0x03a8, L"Ps"),std::make_pair(0x03a9, L"O"), - std::make_pair(0x03c2, L"s"), -}; - -const std::pair latin_greek_[] = { - std::make_pair(L"a", 0x03b1), std::make_pair(L"b", 0x03b2), - std::make_pair(L"c", 0x03c7), std::make_pair(L"d", 0x03b4), - std::make_pair(L"e", 0x03b5), std::make_pair(L"f", 0x03c6), - std::make_pair(L"g", 0x03b3), std::make_pair(L"h", 0x03c7), - std::make_pair(L"i", 0x03b9), std::make_pair(L"j", 0x03b7), - std::make_pair(L"k", 0x03ba), std::make_pair(L"l", 0x03bb), - std::make_pair(L"m", 0x03bc), std::make_pair(L"n", 0x03bd), - std::make_pair(L"o", 0x03bf), std::make_pair(L"p", 0x03c0), - std::make_pair(L"ps", 0x03c8),std::make_pair(L"q", 0x03ba), - std::make_pair(L"r", 0x03c1), std::make_pair(L"s", 0x03c3), - std::make_pair(L"t", 0x03c4), std::make_pair(L"th", 0x03b8), - std::make_pair(L"u", 0x03c5), std::make_pair(L"v", 0x03c6), - std::make_pair(L"w", 0x03c5), std::make_pair(L"x", 0x03be), - std::make_pair(L"y", 0x03c5), std::make_pair(L"z", 0x03b6), - std::make_pair(L"A", 0x0391), std::make_pair(L"B", 0x0392), - std::make_pair(L"C", 0x03a7), std::make_pair(L"D", 0x0394), - std::make_pair(L"E", 0x0395), std::make_pair(L"F", 0x03a6), - std::make_pair(L"G", 0x0393), std::make_pair(L"H", 0x03a7), - std::make_pair(L"I", 0x0399), std::make_pair(L"J", 0x0397), - std::make_pair(L"K", 0x039a), std::make_pair(L"L", 0x039b), - std::make_pair(L"M", 0x039c), std::make_pair(L"N", 0x039d), - std::make_pair(L"O", 0x039f), std::make_pair(L"P", 0x03a0), - std::make_pair(L"Ps", 0x03a8),std::make_pair(L"Q", 0x039a), - std::make_pair(L"R", 0x03a1), std::make_pair(L"S", 0x03a3), - std::make_pair(L"U", 0x03a5), std::make_pair(L"V", 0x03a6), - std::make_pair(L"W", 0x03a5), std::make_pair(L"X", 0x039e), - std::make_pair(L"Y", 0x03a5), std::make_pair(L"Z", 0x0396), - std::make_pair(L"T", 0x03a4), std::make_pair(L"Th", 0x0398), - std::make_pair(L"PS", 0x03a8),std::make_pair(L"TH", 0x0398), - - std::make_pair(L"ch", 0x03c7),std::make_pair(L"CH", 0x03a7), - std::make_pair(L"Ch", 0x03a7), -}; - const std::unordered_map latin_cyrillic(latin_cyrillic_, latin_cyrillic_ + ARRAYSIZE(latin_cyrillic_)); const std::unordered_map to_latin(to_latin_, to_latin_ + ARRAYSIZE(to_latin_)); const std::unordered_map latin_greek(latin_greek_, latin_greek_ + ARRAYSIZE(latin_greek_)); +const std::unordered_map x_sampa(x_sampa_, + x_sampa_ + ARRAYSIZE(x_sampa_)); inline int randint(int min, int max) { @@ -294,9 +129,23 @@ void MainWindow::OnTextCyrillic() for (; *text; ++text) { temp = wstring(text, 2); + if (latin_cyrillic.count(temp)) { cyrillic.push_back(latin_cyrillic.at(temp)); ++text; + } else if (tolower(*text) == 'c') { + // special handling of C + int lower = tolower(*(text + 1)); + + temp.clear(); + if (lower == 'k') + continue; + else if (lower == 'e' || lower == 'i') + temp.push_back(*text + 16); + else + temp.push_back(*text + 8); + cyrillic.push_back(latin_cyrillic.at(temp)); + continue; } else if (temp.pop_back(), latin_cyrillic.count(temp)) cyrillic.push_back(latin_cyrillic.at(temp)); else @@ -332,7 +181,7 @@ void MainWindow::OnTextLatin() *text == 0x042b || *text == 0x042b) { // -ij to -y if (*text & 0x20) - latin.push_back(L'Y'); + latin.push_back(L'y'); else latin.push_back(L'Y'); ++text; @@ -358,6 +207,19 @@ void MainWindow::OnTextGreek() if (latin_greek.count(temp)) { greek.push_back(latin_greek.at(temp)); ++text; + } else if (tolower(*text) == 'c') { + // special handling of C + int lower = tolower(*(text + 1)); + + temp.clear(); + if (lower == 'k') + continue; + else if (lower == 'e' || lower == 'i') + temp.push_back(*text + 16); + else + temp.push_back(*text + 8); + greek.push_back(latin_greek.at(temp)); + continue; } else if (temp.pop_back(), latin_greek.count(temp)) greek.push_back(latin_greek.at(temp)); else @@ -372,3 +234,29 @@ void MainWindow::OnTextGreek() LocalUnlock(buf); Edit_SetText(m_message, greek.c_str()); } + +void MainWindow::OnTextXSAMPA() +{ + HLOCAL buf = Edit_GetHandle(m_message); + wstring ipa, temp; + LPWSTR text = (LPWSTR) LocalLock(buf); + + for (; *text; ++text) { + temp = wstring(text, 4); + + while (!temp.empty()) { + if (x_sampa.count(temp)) { + wchar_t out = x_sampa.at(temp); + if (out) + ipa.push_back(out); + text += temp.length() - 1; + break; + } else temp.pop_back(); + } + + if (temp.empty()) + ipa.push_back(*text); + } + LocalUnlock(buf); + Edit_SetText(m_message, ipa.c_str()); +} diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index a2e1fdc..b57a5bf 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -143,6 +143,9 @@ LRESULT MainWindow::OnCreate() m_greek = CreateWindow(WC_BUTTON, L"Use G&reek", WS_CHILDWINDOW | WS_VISIBLE | BS_PUSHBUTTON, 0, 0, 0, 0, m_hwnd, (HMENU) ZALGO_GREEK, GetInstance(), NULL); + m_xsampa = CreateWindow(WC_BUTTON, L"&X-SAMPA to IPA", + WS_CHILDWINDOW | WS_VISIBLE | BS_PUSHBUTTON, 0, 0, 0, 0, + m_hwnd, (HMENU) ZALGO_XSAMPA, GetInstance(), NULL); PostMessage(m_messUpDown, UDM_SETRANGE32, 1, ZALGO_MESS_LEVEL_OF(ZALGO_MAX_MESS)); PostMessage(m_messUpDown, UDM_SETPOS32, 0, ZALGO_MESS_LEVEL_OF(ZALGO_NORMAL_MESS)); @@ -164,6 +167,7 @@ LRESULT MainWindow::OnCreate() SETFONT(m_latin); SETFONT(m_cyrillic); SETFONT(m_greek); + SETFONT(m_xsampa); #undef SETFONT Button_SetCheck(m_goUp, 1); @@ -207,6 +211,7 @@ LRESULT MainWindow::OnDestroy() DestroyWindow(m_latin); DestroyWindow(m_cyrillic); DestroyWindow(m_greek); + DestroyWindow(m_xsampa); delete m_preview; return 0; } @@ -251,7 +256,8 @@ LRESULT MainWindow::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) REPOS(m_messNormal, BOTTOM(160, client.bottom - 34, 120, 20)); REPOS(m_messMax, BOTTOM(160, client.bottom - 9, 120, 20)); REPOS(m_messCustom, BOTTOM(280, client.bottom - 59, 120, 20)); - REPOS(m_messLevel, BOTTOM(280, client.bottom - 38, 100, 20)); + REPOS(m_messLevel, BOTTOM(280, client.bottom - 38, 84, 20)); + REPOS(m_messUpDown, BOTTOM(362, client.bottom - 38, 18, 20)); REPOS(m_mess, BOTTOMRIGHT(client.right - 12, client.bottom - 41, 100, 25)); REPOS(m_unmess, BOTTOMRIGHT(client.right - 12, client.bottom - 12, 100, 25)); REPOS(m_nfc, BOTTOMRIGHT(client.right - 117, client.bottom - 41, 50, 25)); @@ -260,9 +266,9 @@ LRESULT MainWindow::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) REPOS(m_latin, BOTTOM(12, client.bottom - 84, 100, 25)); REPOS(m_cyrillic, BOTTOM(117, client.bottom - 84, 100, 25)); REPOS(m_greek, BOTTOM(222, client.bottom - 84, 100, 25)); + REPOS(m_xsampa, BOTTOM(327, client.bottom - 84, 100, 25)); EndDeferWindowPos(hdwp); #undef REPOS - PostMessage(m_messUpDown, UDM_SETBUDDY, (WPARAM) m_messLevel, 0); return 0; } case WM_COMMAND: @@ -300,6 +306,9 @@ LRESULT MainWindow::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) case ZALGO_GREEK: OnTextGreek(); break; + case ZALGO_XSAMPA: + OnTextXSAMPA(); + break; case ZALGO_GO_UP: case ZALGO_GO_CENTER: case ZALGO_GO_DOWN: