Software /
code /
prosody
Comparison
util-src/encodings.c @ 6665:e923d7cb8430
Merge
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 06 May 2015 19:21:29 +0100 |
parent | 6643:127b9f0c6135 |
child | 6789:6b180e77c97a |
comparison
equal
deleted
inserted
replaced
6664:5466f24e51c9 | 6665:e923d7cb8430 |
---|---|
474 #include <idn-free.h> | 474 #include <idn-free.h> |
475 | 475 |
476 static int Lidna_to_ascii(lua_State* L) { /** idna.to_ascii(s) */ | 476 static int Lidna_to_ascii(lua_State* L) { /** idna.to_ascii(s) */ |
477 size_t len; | 477 size_t len; |
478 const char* s = check_utf8(L, 1, &len); | 478 const char* s = check_utf8(L, 1, &len); |
479 char* output = NULL; | |
480 int ret; | |
479 | 481 |
480 if(s == NULL || len != strlen(s)) { | 482 if(s == NULL || len != strlen(s)) { |
481 lua_pushnil(L); | 483 lua_pushnil(L); |
482 return 1; /* TODO return error message */ | 484 return 1; /* TODO return error message */ |
483 } | 485 } |
484 | 486 |
485 char* output = NULL; | 487 ret = idna_to_ascii_8z(s, &output, IDNA_USE_STD3_ASCII_RULES); |
486 int ret = idna_to_ascii_8z(s, &output, IDNA_USE_STD3_ASCII_RULES); | |
487 | 488 |
488 if(ret == IDNA_SUCCESS) { | 489 if(ret == IDNA_SUCCESS) { |
489 lua_pushstring(L, output); | 490 lua_pushstring(L, output); |
490 idn_free(output); | 491 idn_free(output); |
491 return 1; | 492 return 1; |