|
Lines 60-70
Link Here
|
| 60 |
* Return number of bytes consumed |
60 |
* Return number of bytes consumed |
| 61 |
*/ |
61 |
*/ |
| 62 |
int |
62 |
int |
| 63 |
isochar(isofn, isoend, joliet_level, c) |
63 |
isochar(isofn, isoend, joliet_level, c, utf_state) |
| 64 |
u_char *isofn; |
64 |
u_char *isofn; |
| 65 |
u_char *isoend; |
65 |
u_char *isoend; |
| 66 |
int joliet_level; |
66 |
int joliet_level; |
| 67 |
u_char *c; |
67 |
u_char *c; |
|
|
68 |
int *utf_state; |
| 68 |
{ |
69 |
{ |
| 69 |
*c = *isofn++; |
70 |
*c = *isofn++; |
| 70 |
if (joliet_level == 0 || isofn == isoend) |
71 |
if (joliet_level == 0 || isofn == isoend) |
|
Lines 81-90
Link Here
|
| 81 |
break; |
82 |
break; |
| 82 |
} |
83 |
} |
| 83 |
/* XXX: if Unicode conversion routine is loaded then use it */ |
84 |
/* XXX: if Unicode conversion routine is loaded then use it */ |
| 84 |
if (cd9660_wchar2char != NULL) |
85 |
if (cd9660_wchar2char != NULL) { |
| 85 |
*c = cd9660_wchar2char((*(isofn - 1) << 8) | *isofn); |
86 |
*c = cd9660_wchar2char((*(isofn - 1) << 8) | *isofn); |
|
|
87 |
*utf_state = 0; |
| 88 |
} else if (utf_state != NULL) { /* XXX: convert to UTF-8 */ |
| 89 |
static const u_char hex[16] = "0123456789abcdef"; |
| 90 |
int unichar = (*(isofn - 1) << 8) | *isofn; |
| 91 |
if (unichar == '?' || unichar == '%' || unichar <= ' ' |
| 92 |
|| unichar == '\\' || unichar == '/') { |
| 93 |
switch (*utf_state) { |
| 94 |
case 0: |
| 95 |
*c = '%'; |
| 96 |
*utf_state = 1; |
| 97 |
break; |
| 98 |
case 1: |
| 99 |
*c = (u_char)(hex[(unichar >> 4) & 0x0f]); |
| 100 |
*utf_state = 2; |
| 101 |
break; |
| 102 |
default: |
| 103 |
*c = (u_char)(hex[unichar & 0x0f]); |
| 104 |
*utf_state = 0; |
| 105 |
break; |
| 106 |
} |
| 107 |
} else if (unichar < 128) { |
| 108 |
*c = (u_char)(unichar); |
| 109 |
*utf_state = 0; |
| 110 |
} else if ((unichar > 127) && (unichar < 2048)) { |
| 111 |
if (*utf_state == 0) { |
| 112 |
*c = (u_char)((unichar >> 6) | 192); |
| 113 |
*utf_state = 1; |
| 114 |
} else { |
| 115 |
*c = (u_char)((unichar & 63) | 128); |
| 116 |
*utf_state = 0; |
| 117 |
} |
| 118 |
} else { |
| 119 |
switch (*utf_state) { |
| 120 |
case 0: |
| 121 |
*c = (u_char)((unichar >> 12) | 224); |
| 122 |
*utf_state = 1; |
| 123 |
break; |
| 124 |
case 1: |
| 125 |
*c = (u_char)(((unichar >> 6) & 63) | 128); |
| 126 |
*utf_state = 2; |
| 127 |
break; |
| 128 |
default: |
| 129 |
*c = (u_char)((unichar & 63) | 128); |
| 130 |
*utf_state = 0; |
| 131 |
break; |
| 132 |
} |
| 133 |
} |
| 134 |
} |