/*
* linux/fs/nls/nls_base.c
*
* Native language support--charsets and unicode translations.
* By Gordon Chaffee 1996, 1997
*
* Unicode based case conversion 1999 by Wolfram Pienkoss
*
*/
#include <linux/module.h>
#include <linux/string.h>
#include <linux/nls.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/kmod.h>
#include <linux/spinlock.h>
#include <
asm /byteorder.h>
static struct nls_table default_table;
static struct nls_table *tables = &default_table;
static DEFINE_SPINLOCK(nls_lock);
/*
* Sample implementation from Unicode home page.
* http://www.stonehand.com/unicode/standard/fss-utf.html
*/
struct utf8_table {
int cmask;
int cval;
int shift;
long lmask;
long lval;
};
static const struct utf8_table utf8_table[] =
{
{
0 x80,
0 x00,
0 *
6 ,
0 x7F,
0 ,
/* 1 byte sequence */},
{
0 xE0,
0 xC0,
1 *
6 ,
0 x7FF,
0 x80,
/* 2 byte sequence */},
{
0 xF0,
0 xE0,
2 *
6 ,
0 xFFFF,
0 x800,
/* 3 byte sequence */},
{
0 xF8,
0 xF0,
3 *
6 ,
0 x1FFFFF,
0 x10000,
/* 4 byte sequence */},
{
0 xFC,
0 xF8,
4 *
6 ,
0 x3FFFFFF,
0 x200000,
/* 5 byte sequence */},
{
0 xFE,
0 xFC,
5 *
6 ,
0 x7FFFFFFF,
0 x4000000,
/* 6 byte sequence */},
{
0 ,
/* end of table */}
};
#define UNICODE_MAX
0 x0010ffff
#define PLANE_SIZE
0 x00010000
#define SURROGATE_MASK
0 xfffff800
#define SURROGATE_PAIR
0 x0000d800
#define SURROGATE_LOW
0 x00000400
#define SURROGATE_BITS
0 x000003ff
int utf8_to_utf32(
const u8 *s,
int inlen, unicode_t *pu)
{
unsigned long l;
int c0, c, nc;
const struct utf8_table *t;
nc =
0 ;
c0 = *s;
l = c0;
for (t = utf8_table; t->cmask; t++) {
nc++;
if ((c0 & t->cmask) == t->cval) {
l &= t->lmask;
if (l < t->lval || l > UNICODE_MAX ||
(l & SURROGATE_MASK) == SURROGATE_PAIR)
return -
1 ;
*pu = (unicode_t) l;
return nc;
}
if (inlen <= nc)
return -
1 ;
s++;
c = (*s ^
0 x80) &
0 xFF;
if (c &
0 xC0)
return -
1 ;
l = (l <<
6 ) | c;
}
return -
1 ;
}
EXPORT_SYMBOL(utf8_to_utf32);
int utf32_to_utf8(unicode_t u, u8 *s,
int maxout)
{
unsigned long l;
int c, nc;
const struct utf8_table *t;
if (!s)
return 0 ;
l = u;
if (l > UNICODE_MAX || (l & SURROGATE_MASK) == SURROGATE_PAIR)
return -
1 ;
nc =
0 ;
for (t = utf8_table; t->cmask && maxout; t++, maxout--) {
nc++;
if (l <= t->lmask) {
c = t->shift;
*s = (u8) (t->cval | (l >> c));
while (c >
0 ) {
c -=
6 ;
s++;
*s = (u8) (
0 x80 | ((l >> c) &
0 x3F));
}
return nc;
}
}
return -
1 ;
}
EXPORT_SYMBOL(utf32_to_utf8);
static inline void put_utf16(
wchar_t *s,
unsigned c,
enum utf16_endian endian)
{
switch (endian) {
default :
*s = (
wchar_t ) c;
break ;
case UTF16_LITTLE_ENDIAN:
*s = __cpu_to_le16(c);
break ;
case UTF16_BIG_ENDIAN:
*s = __cpu_to_be16(c);
break ;
}
}
int utf8s_to_utf16s(
const u8 *s,
int inlen,
enum utf16_endian endian,
wchar_t *pwcs,
int maxout)
{
u16 *op;
int size;
unicode_t u;
op = pwcs;
while (inlen >
0 && maxout >
0 && *s) {
if (*s &
0 x80) {
size = utf8_to_utf32(s, inlen, &u);
if (size <
0 )
return -EINVAL;
s += size;
inlen -= size;
if (u >= PLANE_SIZE) {
if (maxout <
2 )
break ;
u -= PLANE_SIZE;
put_utf16(op++, SURROGATE_PAIR |
((u >>
10 ) & SURROGATE_BITS),
endian);
put_utf16(op++, SURROGATE_PAIR |
SURROGATE_LOW |
(u & SURROGATE_BITS),
endian);
maxout -=
2 ;
}
else {
put_utf16(op++, u, endian);
maxout--;
}
}
else {
put_utf16(op++, *s++, endian);
inlen--;
maxout--;
}
}
return op - pwcs;
}
EXPORT_SYMBOL(utf8s_to_utf16s);
static inline unsigned long get_utf16(
unsigned c,
enum utf16_endian endian)
{
switch (endian) {
default :
return c;
case UTF16_LITTLE_ENDIAN:
return __le16_to_cpu(c);
case UTF16_BIG_ENDIAN:
return __be16_to_cpu(c);
}
}
int utf16s_to_utf8s(
const wchar_t *pwcs,
int inlen,
enum utf16_endian endian,
u8 *s,
int maxout)
{
u8 *op;
int size;
unsigned long u, v;
op = s;
while (inlen >
0 && maxout >
0 ) {
u = get_utf16(*pwcs, endian);
if (!u)
break ;
pwcs++;
inlen--;
if (u >
0 x7f) {
if ((u & SURROGATE_MASK) == SURROGATE_PAIR) {
if (u & SURROGATE_LOW) {
/* Ignore character and move on */
continue ;
}
if (inlen <=
0 )
break ;
v = get_utf16(*pwcs, endian);
if ((v & SURROGATE_MASK) != SURROGATE_PAIR ||
!(v & SURROGATE_LOW)) {
/* Ignore character and move on */
continue ;
}
u = PLANE_SIZE + ((u & SURROGATE_BITS) <<
10 )
+ (v & SURROGATE_BITS);
pwcs++;
inlen--;
}
size = utf32_to_utf8(u, op, maxout);
if (size == -
1 ) {
/* Ignore character and move on */
}
else {
op += size;
maxout -= size;
}
}
else {
*op++ = (u8) u;
maxout--;
}
}
return op - s;
}
EXPORT_SYMBOL(utf16s_to_utf8s);
int __register_nls(
struct nls_table *nls,
struct module *owner)
{
struct nls_table ** tmp = &tables;
if (nls->next)
return -EBUSY;
nls->owner = owner;
spin_lock(&nls_lock);
while (*tmp) {
if (nls == *tmp) {
spin_unlock(&nls_lock);
return -EBUSY;
}
tmp = &(*tmp)->next;
}
nls->next = tables;
tables = nls;
spin_unlock(&nls_lock);
return 0 ;
}
EXPORT_SYMBOL(__register_nls);
int unregister_nls(
struct nls_table * nls)
{
struct nls_table ** tmp = &tables;
spin_lock(&nls_lock);
while (*tmp) {
if (nls == *tmp) {
*tmp = nls->next;
spin_unlock(&nls_lock);
return 0 ;
}
tmp = &(*tmp)->next;
}
spin_unlock(&nls_lock);
return -EINVAL;
}
static struct nls_table *find_nls(
const char *charset)
{
struct nls_table *nls;
spin_lock(&nls_lock);
for (nls = tables; nls; nls = nls->next) {
if (!strcmp(nls->charset, charset))
break ;
if (nls->alias && !strcmp(nls->alias, charset))
break ;
}
if (nls && !try_module_get(nls->owner))
nls = NULL;
spin_unlock(&nls_lock);
return nls;
}
struct nls_table *load_nls(
const char *charset)
{
return try_then_request_module(find_nls(charset),
"nls_%s" , charset);
}
void unload_nls(
struct nls_table *nls)
{
if (nls)
module_put(nls->owner);
}
static const wchar_t charset2uni[
256 ] = {
/* 0x00*/
0 x0000,
0 x0001,
0 x0002,
0 x0003,
0 x0004,
0 x0005,
0 x0006,
0 x0007,
0 x0008,
0 x0009,
0 x000a,
0 x000b,
0 x000c,
0 x000d,
0 x000e,
0 x000f,
/* 0x10*/
0 x0010,
0 x0011,
0 x0012,
0 x0013,
0 x0014,
0 x0015,
0 x0016,
0 x0017,
0 x0018,
0 x0019,
0 x001a,
0 x001b,
0 x001c,
0 x001d,
0 x001e,
0 x001f,
/* 0x20*/
0 x0020,
0 x0021,
0 x0022,
0 x0023,
0 x0024,
0 x0025,
0 x0026,
0 x0027,
0 x0028,
0 x0029,
0 x002a,
0 x002b,
0 x002c,
0 x002d,
0 x002e,
0 x002f,
/* 0x30*/
0 x0030,
0 x0031,
0 x0032,
0 x0033,
0 x0034,
0 x0035,
0 x0036,
0 x0037,
0 x0038,
0 x0039,
0 x003a,
0 x003b,
0 x003c,
0 x003d,
0 x003e,
0 x003f,
/* 0x40*/
0 x0040,
0 x0041,
0 x0042,
0 x0043,
0 x0044,
0 x0045,
0 x0046,
0 x0047,
0 x0048,
0 x0049,
0 x004a,
0 x004b,
0 x004c,
0 x004d,
0 x004e,
0 x004f,
/* 0x50*/
0 x0050,
0 x0051,
0 x0052,
0 x0053,
0 x0054,
0 x0055,
0 x0056,
0 x0057,
0 x0058,
0 x0059,
0 x005a,
0 x005b,
0 x005c,
0 x005d,
0 x005e,
0 x005f,
/* 0x60*/
0 x0060,
0 x0061,
0 x0062,
0 x0063,
0 x0064,
0 x0065,
0 x0066,
0 x0067,
0 x0068,
0 x0069,
0 x006a,
0 x006b,
0 x006c,
0 x006d,
0 x006e,
0 x006f,
/* 0x70*/
0 x0070,
0 x0071,
0 x0072,
0 x0073,
0 x0074,
0 x0075,
0 x0076,
0 x0077,
0 x0078,
0 x0079,
0 x007a,
0 x007b,
0 x007c,
0 x007d,
0 x007e,
0 x007f,
/* 0x80*/
0 x0080,
0 x0081,
0 x0082,
0 x0083,
0 x0084,
0 x0085,
0 x0086,
0 x0087,
0 x0088,
0 x0089,
0 x008a,
0 x008b,
0 x008c,
0 x008d,
0 x008e,
0 x008f,
/* 0x90*/
0 x0090,
0 x0091,
0 x0092,
0 x0093,
0 x0094,
0 x0095,
0 x0096,
0 x0097,
0 x0098,
0 x0099,
0 x009a,
0 x009b,
0 x009c,
0 x009d,
0 x009e,
0 x009f,
/* 0xa0*/
0 x00a0,
0 x00a1,
0 x00a2,
0 x00a3,
0 x00a4,
0 x00a5,
0 x00a6,
0 x00a7,
0 x00a8,
0 x00a9,
0 x00aa,
0 x00ab,
0 x00ac,
0 x00ad,
0 x00ae,
0 x00af,
/* 0xb0*/
0 x00b0,
0 x00b1,
0 x00b2,
0 x00b3,
0 x00b4,
0 x00b5,
0 x00b6,
0 x00b7,
0 x00b8,
0 x00b9,
0 x00ba,
0 x00bb,
0 x00bc,
0 x00bd,
0 x00be,
0 x00bf,
/* 0xc0*/
0 x00c0,
0 x00c1,
0 x00c2,
0 x00c3,
0 x00c4,
0 x00c5,
0 x00c6,
0 x00c7,
0 x00c8,
0 x00c9,
0 x00ca,
0 x00cb,
0 x00cc,
0 x00cd,
0 x00ce,
0 x00cf,
/* 0xd0*/
0 x00d0,
0 x00d1,
0 x00d2,
0 x00d3,
0 x00d4,
0 x00d5,
0 x00d6,
0 x00d7,
0 x00d8,
0 x00d9,
0 x00da,
0 x00db,
0 x00dc,
0 x00dd,
0 x00de,
0 x00df,
/* 0xe0*/
0 x00e0,
0 x00e1,
0 x00e2,
0 x00e3,
0 x00e4,
0 x00e5,
0 x00e6,
0 x00e7,
0 x00e8,
0 x00e9,
0 x00ea,
0 x00eb,
0 x00ec,
0 x00ed,
0 x00ee,
0 x00ef,
/* 0xf0*/
0 x00f0,
0 x00f1,
0 x00f2,
0 x00f3,
0 x00f4,
0 x00f5,
0 x00f6,
0 x00f7,
0 x00f8,
0 x00f9,
0 x00fa,
0 x00fb,
0 x00fc,
0 x00fd,
0 x00fe,
0 x00ff,
};
static const unsigned char page00[
256 ] = {
0 x00,
0 x01,
0 x02,
0 x03,
0 x04,
0 x05,
0 x06,
0 x07,
/* 0x00-0x07 */
0 x08,
0 x09,
0 x0a,
0 x0b,
0 x0c,
0 x0d,
0 x0e,
0 x0f,
/* 0x08-0x0f */
0 x10,
0 x11,
0 x12,
0 x13,
0 x14,
0 x15,
0 x16,
0 x17,
/* 0x10-0x17 */
0 x18,
0 x19,
0 x1a,
0 x1b,
0 x1c,
0 x1d,
0 x1e,
0 x1f,
/* 0x18-0x1f */
0 x20,
0 x21,
0 x22,
0 x23,
0 x24,
0 x25,
0 x26,
0 x27,
/* 0x20-0x27 */
0 x28,
0 x29,
0 x2a,
0 x2b,
0 x2c,
0 x2d,
0 x2e,
0 x2f,
/* 0x28-0x2f */
0 x30,
0 x31,
0 x32,
0 x33,
0 x34,
0 x35,
0 x36,
0 x37,
/* 0x30-0x37 */
0 x38,
0 x39,
0 x3a,
0 x3b,
0 x3c,
0 x3d,
0 x3e,
0 x3f,
/* 0x38-0x3f */
0 x40,
0 x41,
0 x42,
0 x43,
0 x44,
0 x45,
0 x46,
0 x47,
/* 0x40-0x47 */
0 x48,
0 x49,
0 x4a,
0 x4b,
0 x4c,
0 x4d,
0 x4e,
0 x4f,
/* 0x48-0x4f */
0 x50,
0 x51,
0 x52,
0 x53,
0 x54,
0 x55,
0 x56,
0 x57,
/* 0x50-0x57 */
0 x58,
0 x59,
0 x5a,
0 x5b,
0 x5c,
0 x5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d7 */
0 xd8,
0 xd9,
0 xda,
0 xdb,
0 xdc,
0 xdd,
0 xde,
0 xdf,
/* 0xd8-0xdf */
0 xe0,
0 xe1,
0 xe2,
0 xe3,
0 xe4,
0 xe5,
0 xe6,
0 xe7,
/* 0xe0-0xe7 */
0 xe8,
0 xe9,
0 xea,
0 xeb,
0 xec,
0 xed,
0 xee,
0 xef,
/* 0xe8-0xef */
0 xf0,
0 xf1,
0 xf2,
0 xf3,
0 xf4,
0 xf5,
0 xf6,
0 xf7,
/* 0xf0-0xf7 */
0 xf8,
0 xf9,
0 xfa,
0 xfb,
0 xfc,
0 xfd,
0 xfe,
0 xff,
/* 0xf8-0xff */
};
static const unsigned char *
const page_uni2charset[
256 ] = {
page00
};
static const unsigned char charset2lower[
256 ] = {
0 x00,
0 x01,
0 x02,
0 x03,
0 x04,
0 x05,
0 x06,
0 x07,
/* 0x00-0x07 */
0 x08,
0 x09,
0 x0a,
0 x0b,
0 x0c,
0 x0d,
0 x0e,
0 x0f,
/* 0x08-0x0f */
0 x10,
0 x11,
0 x12,
0 x13,
0 x14,
0 x15,
0 x16,
0 x17,
/* 0x10-0x17 */
0 x18,
0 x19,
0 x1a,
0 x1b,
0 x1c,
0 x1d,
0 x1e,
0 x1f,
/* 0x18-0x1f */
0 x20,
0 x21,
0 x22,
0 x23,
0 x24,
0 x25,
0 x26,
0 x27,
/* 0x20-0x27 */
0 x28,
0 x29,
0 x2a,
0 x2b,
0 x2c,
0 x2d,
0 x2e,
0 x2f,
/* 0x28-0x2f */
0 x30,
0 x31,
0 x32,
0 x33,
0 x34,
0 x35,
0 x36,
0 x37,
/* 0x30-0x37 */
0 x38,
0 x39,
0 x3a,
0 x3b,
0 x3c,
0 x3d,
0 x3e,
0 x3f,
/* 0x38-0x3f */
0 x40,
0 x61,
0 x62,
0 x63,
0 x64,
0 x65,
0 x66,
0 x67,
/* 0x40-0x47 */
0 x68,
0 x69,
0 x6a,
0 x6b,
0 x6c,
0 x6d,
0 x6e,
0 x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
0 xcb,
0 xcc,
0 xcd,
0 xce,
0 xcf,
/* 0xc8-0xcf */
0 xd0,
0 xd1,
0 xd2,
0 xd3,
0 xd4,
0 xd5,
0 xd6,
0 xd7,
/* 0xd0-0xd7 */
0 xd8,
0 xd9,
0 xda,
0 xdb,
0 xdc,
0 xdd,
0 xde,
0 xdf,
/* 0xd8-0xdf */
0 xe0,
0 xe1,
0 xe2,
0 xe3,
0 xe4,
0 xe5,
0 xe6,
0 xe7,
/* 0xe0-0xe7 */
0 xe8,
0 xe9,
0 xea,
0 xeb,
0 xec,
0 xed,
0 xee,
0 xef,
/* 0xe8-0xef */
0 xf0,
0 xf1,
0 xf2,
0 xf3,
0 xf4,
0 xf5,
0 xf6,
0 xf7,
/* 0xf0-0xf7 */
0 xf8,
0 xf9,
0 xfa,
0 xfb,
0 xfc,
0 xfd,
0 xfe,
0 xff,
/* 0xf8-0xff */
};
static const unsigned char charset2upper[
256 ] = {
0 x00,
0 x01,
0 x02,
0 x03,
0 x04,
0 x05,
0 x06,
0 x07,
/* 0x00-0x07 */
0 x08,
0 x09,
0 x0a,
0 x0b,
0 x0c,
0 x0d,
0 x0e,
0 x0f,
/* 0x08-0x0f */
0 x10,
0 x11,
0 x12,
0 x13,
0 x14,
0 x15,
0 x16,
0 x17,
/* 0x10-0x17 */
0 x18,
0 x19,
0 x1a,
0 x1b,
0 x1c,
0 x1d,
0 x1e,
0 x1f,
/* 0x18-0x1f */
0 x20,
0 x21,
0 x22,
0 x23,
0 x24,
0 x25,
0 x26,
0 x27,
/* 0x20-0x27 */
0 x28,
0 x29,
0 x2a,
0 x2b,
0 x2c,
0 x2d,
0 x2e,
0 x2f,
/* 0x28-0x2f */
0 x30,
0 x31,
0 x32,
0 x33,
0 x34,
0 x35,
0 x36,
0 x37,
/* 0x30-0x37 */
0 x38,
0 x39,
0 x3a,
0 x3b,
0 x3c,
0 x3d,
0 x3e,
0 x3f,
/* 0x38-0x3f */
0 x40,
0 x41,
0 x42,
0 x43,
0 x44,
0 x45,
0 x46,
0 x47,
/* 0x40-0x47 */
0 x48,
0 x49,
0 x4a,
0 x4b,
0 x4c,
0 x4d,
0 x4e,
0 x4f,
/* 0x48-0x4f */
0 x50,
0 x51,
0 x52,
0 x53,
0 x54,
0 x55,
0 x56,
0 x57,
/* 0x50-0x57 */
0 x58,
0 x59,
0 x5a,
0 x5b,
0 x5c,
0 x5d,
0 x5e,
0 x5f,
/* 0x58-0x5f */
0 x60,
0 x41,
0 x42,
0 x43,
0 x44,
0 x45,
0 x46,
0 x47,
/* 0x60-0x67 */
0 x48,
0 x49,
0 x4a,
0 x4b,
0 x4c,
0 x4d,
0 x4e,
0 x4f,
/* 0x68-0x6f */
0 x50,
0 x51,
0 x52,
0 x53,
0 x54,
0 x55,
0 x56,
0 x57,
/* 0x70-0x77 */
0 x58,
0 x59,
0 x5a,
0 x7b,
0 x7c,
0 x7d,
0 x7e,
0 x7f,
/* 0x78-0x7f */
0 x80,
0 x81,
0 x82,
0 x83,
0 x84,
0 x85,
0 x86,
0 x87,
/* 0x80-0x87 */
0 x88,
0 x89,
0 x8a,
0 x8b,
0 x8c,
0 x8d,
0 x8e,
0 x8f,
/* 0x88-0x8f */
0 x90,
0 x91,
0 x92,
0 x93,
0 x94,
0 x95,
0 x96,
0 x97,
/* 0x90-0x97 */
0 x98,
0 x99,
0 x9a,
0 x9b,
0 x9c,
0 x9d,
0 x9e,
0 x9f,
/* 0x98-0x9f */
0 xa0,
0 xa1,
0 xa2,
0 xa3,
0 xa4,
0 xa5,
0 xa6,
0 xa7,
/* 0xa0-0xa7 */
0 xa8,
0 xa9,
0 xaa,
0 xab,
0 xac,
0 xad,
0 xae,
0 xaf,
/* 0xa8-0xaf */
0 xb0,
0 xb1,
0 xb2,
0 xb3,
0 xb4,
0 xb5,
0 xb6,
0 xb7,
/* 0xb0-0xb7 */
0 xb8,
0 xb9,
0 xba,
0 xbb,
0 xbc,
0 xbd,
0 xbe,
0 xbf,
/* 0xb8-0xbf */
0 xc0,
0 xc1,
0 xc2,
0 xc3,
0 xc4,
0 xc5,
0 xc6,
0 xc7,
/* 0xc0-0xc7 */
0 xc8,
0 xc9,
0 xca,
0 xcb,
0 xcc,
0 xcd,
0 xce,
0 xcf,
/* 0xc8-0xcf */
0 xd0,
0 xd1,
0 xd2,
0 xd3,
0 xd4,
0 xd5,
0 xd6,
0 xd7,
/* 0xd0-0xd7 */
0 xd8,
0 xd9,
0 xda,
0 xdb,
0 xdc,
0 xdd,
0 xde,
0 xdf,
/* 0xd8-0xdf */
0 xe0,
0 xe1,
0 xe2,
0 xe3,
0 xe4,
0 xe5,
0 xe6,
0 xe7,
/* 0xe0-0xe7 */
0 xe8,
0 xe9,
0 xea,
0 xeb,
0 xec,
0 xed,
0 xee,
0 xef,
/* 0xe8-0xef */
0 xf0,
0 xf1,
0 xf2,
0 xf3,
0 xf4,
0 xf5,
0 xf6,
0 xf7,
/* 0xf0-0xf7 */
0 xf8,
0 xf9,
0 xfa,
0 xfb,
0 xfc,
0 xfd,
0 xfe,
0 xff,
/* 0xf8-0xff */
};
static int uni2char(
wchar_t uni,
unsigned char *out,
int boundlen)
{
const unsigned char *uni2charset;
unsigned char cl = uni &
0 x00ff;
unsigned char ch = (uni &
0 xff00) >>
8 ;
if (boundlen <=
0 )
return -ENAMETOOLONG;
uni2charset = page_uni2charset[ch];
if (uni2charset && uni2charset[cl])
out[
0 ] = uni2charset[cl];
else
return -EINVAL;
return 1 ;
}
static int char2uni(
const unsigned char *rawstring,
int boundlen,
wchar_t *uni)
{
*uni = charset2uni[*rawstring];
if (*uni ==
0 x0000)
return -EINVAL;
return 1 ;
}
static struct nls_table default_table = {
.charset =
"default" ,
.uni2char = uni2char,
.char2uni = char2uni,
.charset2lower = charset2lower,
.charset2upper = charset2upper,
};
/* Returns a simple default translation table */
struct nls_table *load_nls_default(
void )
{
struct nls_table *default_nls;
default_nls = load_nls(CONFIG_NLS_DEFAULT);
if (default_nls != NULL)
return default_nls;
else
return &default_table;
}
EXPORT_SYMBOL(unregister_nls);
EXPORT_SYMBOL(unload_nls);
EXPORT_SYMBOL(load_nls);
EXPORT_SYMBOL(load_nls_default);
MODULE_DESCRIPTION(
"Base file system native language support" );
MODULE_LICENSE(
"Dual BSD/GPL" );
Messung V0.5 in Prozent C=78 H=92 G=84
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-06-04)
¤
*© Formatika GbR, Deutschland