mirror of
https://github.com/irssi/irssi.git
synced 2026-08-11 04:43:34 +02:00
Introduce string_policy().
This commit is contained in:
parent
b0afcc96db
commit
2c8648a9c8
2 changed files with 27 additions and 0 deletions
|
|
@ -25,6 +25,8 @@
|
|||
#include "utf8.h"
|
||||
#include "module.h"
|
||||
#include "wcwidth.c"
|
||||
/* Provide is_utf8(): */
|
||||
#include "recode.h"
|
||||
|
||||
int string_advance(char const **str, gboolean utf8)
|
||||
{
|
||||
|
|
@ -41,3 +43,14 @@ int string_advance(char const **str, gboolean utf8)
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int string_policy(const char *str)
|
||||
{
|
||||
if (is_utf8()) {
|
||||
if (!str || g_utf8_validate(str, -1, NULL)) {
|
||||
/* No string provided or valid UTF-8 string: treat as UTF-8: */
|
||||
return TREAT_STRING_AS_UTF8;
|
||||
}
|
||||
}
|
||||
return TREAT_STRING_AS_BYTES;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue