FreeBSD Bugzilla – Attachment 21045 Details for
Bug 36983
CD9660 unicode to utf-8 [hack]
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 2.52 KB, created by
hsw
on 2002-04-11 03:40:01 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
hsw
Created:
2002-04-11 03:40:01 UTC
Size:
2.52 KB
patch
obsolete
>--- cd9660_util.c.orig Fri Mar 2 15:17:36 2001 >+++ cd9660_util.c Wed Apr 10 17:54:12 2002 >@@ -60,11 +60,12 @@ > * Return number of bytes consumed > */ > int >-isochar(isofn, isoend, joliet_level, c) >+isochar(isofn, isoend, joliet_level, c, utf_state) > u_char *isofn; > u_char *isoend; > int joliet_level; > u_char *c; >+ int *utf_state; > { > *c = *isofn++; > if (joliet_level == 0 || isofn == isoend) >@@ -81,10 +82,58 @@ > break; > } > /* XXX: if Unicode conversion routine is loaded then use it */ >- if (cd9660_wchar2char != NULL) >+ if (cd9660_wchar2char != NULL) { > *c = cd9660_wchar2char((*(isofn - 1) << 8) | *isofn); >+ *utf_state = 0; >+ } else if (utf_state != NULL) { /* XXX: convert to UTF-8 */ >+ static const u_char hex[16] = "0123456789abcdef"; >+ int unichar = (*(isofn - 1) << 8) | *isofn; >+ if (unichar == '?' || unichar == '%' || unichar <= ' ' >+ || unichar == '\\' || unichar == '/') { >+ switch (*utf_state) { >+ case 0: >+ *c = '%'; >+ *utf_state = 1; >+ break; >+ case 1: >+ *c = (u_char)(hex[(unichar >> 4) & 0x0f]); >+ *utf_state = 2; >+ break; >+ default: >+ *c = (u_char)(hex[unichar & 0x0f]); >+ *utf_state = 0; >+ break; >+ } >+ } else if (unichar < 128) { >+ *c = (u_char)(unichar); >+ *utf_state = 0; >+ } else if ((unichar > 127) && (unichar < 2048)) { >+ if (*utf_state == 0) { >+ *c = (u_char)((unichar >> 6) | 192); >+ *utf_state = 1; >+ } else { >+ *c = (u_char)((unichar & 63) | 128); >+ *utf_state = 0; >+ } >+ } else { >+ switch (*utf_state) { >+ case 0: >+ *c = (u_char)((unichar >> 12) | 224); >+ *utf_state = 1; >+ break; >+ case 1: >+ *c = (u_char)(((unichar >> 6) & 63) | 128); >+ *utf_state = 2; >+ break; >+ default: >+ *c = (u_char)((unichar & 63) | 128); >+ *utf_state = 0; >+ break; >+ } >+ } >+ }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 36983
: 21045 |
21046