示例#1
0
/* Test al_ustr_find_replace, al_ustr_find_replace_cstr. */
static void t49(void)
{
   ALLEGRO_USTR *us;
   ALLEGRO_USTR_INFO findi;
   ALLEGRO_USTR_INFO repli;
   const ALLEGRO_USTR *find;
   const ALLEGRO_USTR *repl;

   us = al_ustr_new("aábdðeéfghiíaábdðeéfghií");
   find = al_ref_cstr(&findi, "ðeéf");
   repl = al_ref_cstr(&repli, "deef");

   CHECK(al_ustr_find_replace(us, 0, find, repl));
   CHECK(0 == strcmp(al_cstr(us), "aábddeefghiíaábddeefghií"));

   find = al_ref_cstr(&findi, "aá");
   repl = al_ref_cstr(&repli, "AÁ");

   CHECK(al_ustr_find_replace(us, 14, find, repl));
   CHECK(0 == strcmp(al_cstr(us), "aábddeefghiíAÁbddeefghií"));

   CHECK(al_ustr_find_replace_cstr(us, 0, "dd", "đ"));
   CHECK(0 == strcmp(al_cstr(us), "aábđeefghiíAÁbđeefghií"));

   /* Not allowed */
   find = al_ustr_empty_string();
   CHECK(! al_ustr_find_replace(us, 0, find, repl));
   CHECK(0 == strcmp(al_cstr(us), "aábđeefghiíAÁbđeefghií"));

   al_ustr_free(us);
}
示例#2
0
文件: utf8.c 项目: sesc4mt/mvcdecoder
/* Function: al_ustr_find_replace_cstr
 */
bool al_ustr_find_replace_cstr(ALLEGRO_USTR *us, int start_pos,
   const char *find, const char *replace)
{
   ALLEGRO_USTR_INFO find_info;
   ALLEGRO_USTR_INFO repl_info;
   ALLEGRO_USTR *find_us = al_ref_cstr(&find_info, find);
   ALLEGRO_USTR *repl_us = al_ref_cstr(&repl_info, replace);

   return al_ustr_find_replace(us, start_pos, find_us, repl_us);
}