| * Module for handling utf8 just like any other charset. |
| #include <linux/module.h> |
| #include <linux/kernel.h> |
| #include <linux/string.h> |
| static unsigned char identity[256]; |
| static int uni2char(wchar_t uni, unsigned char *out, int boundlen) |
| n = utf32_to_utf8(uni, out, boundlen); |
| static int char2uni(const unsigned char *rawstring, int boundlen, wchar_t *uni) |
| n = utf8_to_utf32(rawstring, boundlen, &u); |
| if (n < 0 || u > MAX_WCHAR_T) { |
| static struct nls_table table = { |
| .charset2lower = identity, /* no conversion */ |
| .charset2upper = identity, |
| static int __init init_nls_utf8(void) |
| return register_nls(&table); |
| static void __exit exit_nls_utf8(void) |
| module_init(init_nls_utf8) |
| module_exit(exit_nls_utf8) |
| MODULE_LICENSE("Dual BSD/GPL"); |