linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 5/8] Support non-BMP characters on Joliet.
@ 2012-05-15 23:07 Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 0 replies; only message in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2012-05-15 23:07 UTC (permalink / raw)
  To: linux-fsdevel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1220 bytes --]


Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
---
 fs/isofs/joliet.c |   23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/fs/isofs/joliet.c b/fs/isofs/joliet.c
index a048de8..d85e842 100644
--- a/fs/isofs/joliet.c
+++ b/fs/isofs/joliet.c
@@ -16,22 +16,35 @@
 static int
 uni16_to_x8(unsigned char *ascii, __be16 *uni, int len, struct nls_table *nls)
 {
-	__be16 *ip, ch;
+	__be16 *ip, ch[2];
 	unsigned char *op;
 
 	ip = uni;
 	op = ascii;
 
-	while ((ch = get_unaligned(ip)) && len) {
+	ch[1] = get_unaligned(ip);
+
+	while (len) {
 		int llen;
-		llen = nls->uni2char(be16_to_cpu(ch), op, NLS_MAX_CHARSET_SIZE);
+		int s;
+		unicode_t uni;
+		ch[0] = ch[1];
+		if (len > 1)
+			ch[1] = get_unaligned(ip + 1);
+		s = utf16s_to_unicode(ch, len > 1 ? 2 : 1, UTF16_BIG_ENDIAN,
+				      &uni);
+		if (s <= 0) {
+			llen = -1;
+			s = 1;
+		} else
+			llen = nls->uni2char(uni, op, NLS_MAX_CHARSET_SIZE);
 		if (llen > 0)
 			op += llen;
 		else
 			*op++ = '?';
-		ip++;
+		ip += s;
 
-		len--;
+		len -= s;
 	}
 	*op = 0;
 	return (op - ascii);
-- 
1.7.10

-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 294 bytes --]

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-05-15 23:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-15 23:07 [PATCH 5/8] Support non-BMP characters on Joliet Vladimir 'φ-coder/phcoder' Serbinenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).