2 * linux/fs/nls/nls_koi8-ru.c
4 * Charset koi8-ru translation based on charset koi8-u.
5 * The Unicode to charset table has only exact mappings.
8 #include <linux/module.h>
9 #include <linux/kernel.h>
10 #include <linux/string.h>
11 #include <linux/nls.h>
12 #include <linux/errno.h>
14 static struct nls_table
*p_nls
;
16 static int uni2char(const wchar_t uni
,
17 unsigned char *out
, int boundlen
)
22 if ((uni
& 0xffaf) == 0x040e || (uni
& 0xffce) == 0x254c) {
23 /* koi8-ru and koi8-u differ only on two characters */
26 else if (uni
== 0x045e)
28 else if (uni
== 0x255d || uni
== 0x256c)
31 return p_nls
->uni2char(uni
, out
, boundlen
);
36 return p_nls
->uni2char(uni
, out
, boundlen
);
39 static int char2uni(const unsigned char *rawstring
, int boundlen
,
44 if ((*rawstring
& 0xef) != 0xae) {
45 /* koi8-ru and koi8-u differ only on two characters */
46 *uni
= (*rawstring
& 0x10) ? 0x040e : 0x045e;
50 n
= p_nls
->char2uni(rawstring
, boundlen
, uni
);
54 static struct nls_table table
= {
60 static int __init
init_nls_koi8_ru(void)
62 p_nls
= load_nls("koi8-u");
65 table
.charset2upper
= p_nls
->charset2upper
;
66 table
.charset2lower
= p_nls
->charset2lower
;
67 return register_nls(&table
);
73 static void __exit
exit_nls_koi8_ru(void)
75 unregister_nls(&table
);
79 module_init(init_nls_koi8_ru
)
80 module_exit(exit_nls_koi8_ru
)
82 MODULE_LICENSE("Dual BSD/GPL");