【发布时间】:2016-12-28 10:46:17
【问题描述】:
我正在尝试创建一个服务器,它将以非英语语言提供页面,并且我正在使用以下代码测试 libmicrohttpd:
static int
answer_to_connection(void* cls, struct MHD_Connection* connection,
const char* url, const char* method,
const char* version, const char* upload_data,
size_t* upload_data_size, void** con_cls)
{
char *page = "<html><head><meta charset='UTF-8'></head><body>हैलो यूनिकोड</body></html>";
struct MHD_Response* response;
int ret;
response =
MHD_create_response_from_buffer(strlen(page), (void *)page,
MHD_RESPMEM_PERSISTENT);
ret = MHD_queue_response(connection, MHD_HTTP_OK, response);
MHD_destroy_response(response);
return ret;
}
但它不起作用和给予?????浏览器上的字符。 谁能告诉我 libmicrohttpd 是否支持 Unicode,如果支持,那么如何?
【问题讨论】:
-
我做到了,但没有运气。
-
看看这里:stackoverflow.com/questions/1696619/…。确保您的字符串采用 UTF-8 格式。如果您使用带有
u8的 C11 编译器前缀字符串为:char *page = u8"<html><head><meta charset='UTF-8'></head><body>हैलो यूनिकोड</body></html>"; -
是的,有效!!!!谢谢,添加这个作为答案,我会标记为正确
标签: html c http unicode server