Example #1
0
/* Test al_ustr_new_from_buffer, al_cstr_dup. */
static void t39(void)
{
   const char s1[] = "Корабът ми на въздушна възглавница\0е пълен със змиорки";
   ALLEGRO_USTR *us;
   char *s2;

   us = al_ustr_new_from_buffer(s1, sizeof(s1) - 1); /* missing NUL term. */
   s2 = al_cstr_dup(us);
   al_ustr_free(us);

   CHECK(0 == strcmp(s1, s2));
   CHECK(0 == memcmp(s1, s2, sizeof(s1))); /* including NUL terminator */

   al_free(s2);
}
Example #2
0
/* Transforms a ruby string value that as han UTF-8 encoding to
* a newly allocated allegro ustr. Must be freed with rbal_ustr_free.
*/
ALLEGRO_USTR * rbal_rbstr_ustr(VALUE rstr) {
  size_t       size = RBH_CSTRLEN(rstr);
  const char * str  = RBH_CSTR(rstr);
  return al_ustr_new_from_buffer(str, size); 
}
Example #3
0
ALLEGRO_USTR *LString::toAllegroUStr() const {
    if (isEmpty()) return 0;
    const std::string &utf8 = toUtf8();
    return al_ustr_new_from_buffer(utf8.c_str(), utf8.size());
}