int test_th_normalize() { const thchar_t* test_str = (const thchar_t *)"§ЎЎ≥їиўЂииўЂии“"; const thchar_t* ans_str = (const thchar_t *)"§Ў≥їўиЂўиЂи“"; thchar_t resBuff[50]; th_normalize(resBuff, test_str, sizeof resBuff); return (strcmp((const char *)resBuff, (const char *)ans_str) == 0) ? 0 : 1; }
static VALUE f_th_normalize(VALUE obj,VALUE v_str) { char *ostr; size_t ostrlen; VALUE ret; ostrlen = RSTRING_LEN(v_str) * 2 + 1; ostr = ALLOC_N(char, ostrlen); th_normalize((thchar_t *)ostr, (thchar_t *)RSTRING_PTR(v_str), ostrlen); ret = rb_str_new2(ostr); free(ostr); return ret; }