babelouest / ulfius

Web Framework to build REST APIs, Webservices or any HTTP endpoint in C language. Can stream large amount of data, integrate JSON data with Jansson, and create websocket services

Home Page:https://babelouest.github.io/ulfius

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Emoji

epshteinmatthew opened this issue · comments

Is it possible to send emojis?

//for example
ulfius_set_string_body_response(response, 200, "🤗");

Hello,

It doesn't seem so, if I try with the following callback function:

int callback_get_test (const struct _u_request * request, struct _u_response * response, void * user_data) {
  ulfius_set_string_body_response(response, 200, "\U0001f602");
  return U_CALLBACK_CONTINUE;
}

the output is not an emojii, but something like 😂

I guess you would have to encode/decode the emojii to send it to the client.

My bad, a nice person just told me I forgot to set the content-type properly, if you have a callback function like this:

int callback_get_test (const struct _u_request * request, struct _u_response * response, void * user_data) {
  u_map_put(response->map_header, "Content-Type", "text/plain; charset=utf-8");
  ulfius_set_string_body_response(response, 200, "\U0001f602");
  return U_CALLBACK_CONTINUE;
}

You have an emoji displayed in the browser, yay!

thank you very much!