44static const char _xdg_utf8_skip_data[256] = {
45 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
46 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
47 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
48 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
49 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
50 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
51 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
52 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1
64 if( ! ( *source & 0x80 ) )
72 if ( ! (*source & 0x40) )
78 if ( ! (*source & 0x20) )
80 result = *source++ & 0x1F;
83 else if ( ! (*source & 0x10) )
85 result = *source++ & 0x0F;
88 else if ( ! (*source & 0x08) )
90 result = *source++ & 0x07;
93 else if ( ! (*source & 0x04) )
95 result = *source++ & 0x03;
98 else if ( ! (*source & 0x02) )
100 result = *source++ & 0x01;
109 for ( bytelength --; bytelength > 0; bytelength -- )
112 result |= *source++ & 0x3F;
128 if ((source & 0xFF) == source)
143 const char *base_name;
145 if (file_name == NULL)
148 base_name = strrchr (file_name,
'/');
150 if (base_name == NULL)
153 return base_name + 1;
163 out = malloc (
sizeof (
xdg_unichar_t) * (strlen (source) + 1));
170 p = _xdg_utf8_next_char (p);
184 for (i = 0; i < len - i - 1; i++)
187 source[i] = source[len - i - 1];
188 source[len - i - 1] = c;
195 unsigned char *chardata;
198 chardata = (
unsigned char *) data;
199 for (i = 0; i < 128 && i < len; ++i)
201 if (chardata[i] < 32 && chardata[i] != 9 && chardata[i] != 10 && chardata[i] != 13)
202 return XDG_MIME_TYPE_UNKNOWN;
205 return XDG_MIME_TYPE_TEXTPLAIN;
const char *const _xdg_utf8_skip
const char * _xdg_binary_or_text_fallback(const void *data, size_t len)
xdg_unichar_t _xdg_ucs4_to_lower(xdg_unichar_t source)
void _xdg_reverse_ucs4(xdg_unichar_t *source, int len)
const char * _xdg_get_base_name(const char *file_name)
int _xdg_utf8_validate(const char *source)
xdg_unichar_t _xdg_utf8_to_ucs4(const char *source)
xdg_unichar_t * _xdg_convert_to_ucs4(const char *source, int *len)
unsigned int xdg_unichar_t