summaryrefslogtreecommitdiff
blob: 9c565794bf3f75705f1ad5392161493686ff70da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
diff -Naurp cdrtools-2.01.01.orig/include/schily/unls.h cdrtools-2.01.01/include/schily/unls.h
--- cdrtools-2.01.01.orig/include/schily/unls.h	2006-10-10 10:24:15.000000000 +0200
+++ cdrtools-2.01.01/include/schily/unls.h	2006-10-28 16:59:33.000000000 +0200
@@ -23,6 +23,10 @@
 #include <schily/mconfig.h>
 #endif
 
+#ifdef USE_ICONV
+#include <iconv.h>
+#endif
+
 #ifdef	__cplusplus
 extern "C" {
 #endif
@@ -37,6 +41,9 @@ struct unls_table {
 	unsigned char 	**unls_uni2cs;		/* Unicode -> Charset	*/
 	struct unls_unicode *unls_cs2uni;	/* Charset -> Unicode	*/
 	struct unls_table *unls_next;		/* Next table		*/
+#ifdef USE_ICONV
+	iconv_t iconv_d;
+#endif
 };
 
 extern int		init_unls		__PR((void));
@@ -48,6 +55,9 @@ extern struct unls_table *load_unls		__P
 extern void 		unload_unls		__PR((struct unls_table *));
 extern struct unls_table *load_unls_default	__PR((void));
 extern int		init_unls_file		__PR((char * name));
+#ifdef USE_ICONV
+extern int		init_unls_iconv		__PR((char * name));
+#endif
 
 #ifdef	__cplusplus
 }
diff -Naurp cdrtools-2.01.01.orig/libunls/libunls.mk cdrtools-2.01.01/libunls/libunls.mk
--- cdrtools-2.01.01.orig/libunls/libunls.mk	2000-03-25 13:51:56.000000000 +0100
+++ cdrtools-2.01.01/libunls/libunls.mk	2006-10-28 16:59:33.000000000 +0200
@@ -8,6 +8,7 @@ include		$(SRCROOT)/$(RULESDIR)/rules.to
 INSDIR=		lib
 TARGETLIB=	unls
 #CPPOPTS +=	-Istdio
+CPPOPTS +=	-DUSE_ICONV
 include		Targets
 LIBS=		
 
diff -Naurp cdrtools-2.01.01.orig/libunls/nls.h cdrtools-2.01.01/libunls/nls.h
--- cdrtools-2.01.01.orig/libunls/nls.h	2006-09-13 17:09:14.000000000 +0200
+++ cdrtools-2.01.01/libunls/nls.h	2006-10-28 16:59:33.000000000 +0200
@@ -110,5 +110,8 @@ extern int init_unls_cp10029	__PR((void)
 extern int init_unls_cp10079	__PR((void));
 extern int init_unls_cp10081	__PR((void));
 extern int init_unls_file	__PR((char * name));
+#ifdef USE_ICONV
+extern int init_unls_iconv	__PR((char * name));
+#endif
 
 #endif	/* _NLS_H */
diff -Naurp cdrtools-2.01.01.orig/libunls/nls_iconv.c cdrtools-2.01.01/libunls/nls_iconv.c
--- cdrtools-2.01.01.orig/libunls/nls_iconv.c	1970-01-01 01:00:00.000000000 +0100
+++ cdrtools-2.01.01/libunls/nls_iconv.c	2006-10-28 16:58:38.000000000 +0200
@@ -0,0 +1,80 @@
+/* @(#)nls_iconv.c     1.0 02/04/20 2002 J. Schilling  */
+#ifndef lint
+static char sccsid[] =
+       "@(#)nls_iconv.c        1.0 02/01/20 2002 J. Schilling";
+#endif
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING.  If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+/*
+ *     Modifications to make the code portable Copyright (c) 2000 J. Schilling
+ *
+ * nls_iconv: create a pseudo-charset table to use iconv() provided by C
+ * library or libiconv by Bruno Haible
+ * The Unicode to charset table has only exact mappings.
+ *
+ *
+ * Jungshik Shin (jshin@mailaps.org) 04-Feb-2002
+ */
+
+#ifdef USE_ICONV
+#include <mconfig.h>
+#include <stdio.h>
+#include <stdxlib.h>   
+#include <strdefs.h>
+#include "nls.h"
+#include <iconv.h>                                                                                                                                     
+                                                                                                                                                       
+
+int
+init_unls_iconv(charset)
+       char    *charset;
+{
+       iconv_t iconv_d;  /* iconv conversion descriptor */
+       struct unls_table *table;
+
+       /* give up if no charset is given */
+       if (charset == NULL)
+               return -1;
+
+       /* see if we already have a table with this name - built in tables
+          have precedence over iconv() - i.e. can't have the name of an
+          existing table. Also, we may have already registered this file
+          table */
+       if (find_unls(charset) != NULL)
+               return -1;
+
+       if ((iconv_d = iconv_open("UCS-2BE", charset)) == (iconv_t) -1)
+               return -1;
+
+
+       /* set up the table */
+       if ((table = (struct unls_table *)malloc(sizeof (struct unls_table)))
+                                                       == NULL) {
+               return -1;
+       }
+
+       /* give the table the file name, so we can find it again if needed */
+       table->unls_name = strdup(charset);
+       table->iconv_d = iconv_d;
+       table->unls_uni2cs = NULL;
+       table->unls_cs2uni = NULL;
+       table->unls_next = NULL;
+
+       /* register the table */
+       return register_unls(table);
+}
+#endif
+
diff -Naurp cdrtools-2.01.01.orig/libunls/Targets cdrtools-2.01.01/libunls/Targets
--- cdrtools-2.01.01.orig/libunls/Targets	2002-12-03 01:34:27.000000000 +0100
+++ cdrtools-2.01.01/libunls/Targets	2006-10-28 16:59:33.000000000 +0200
@@ -39,4 +39,5 @@ CFILES=	nls_base.c \
 	nls_cp10029.c \
 	nls_cp10079.c \
 	nls_cp10081.c \
-	nls_file.c
+	nls_file.c \
+	nls_iconv.c
diff -Naurp cdrtools-2.01.01.orig/mkisofs/joliet.c cdrtools-2.01.01/mkisofs/joliet.c
--- cdrtools-2.01.01.orig/mkisofs/joliet.c	2006-10-08 15:48:36.000000000 +0200
+++ cdrtools-2.01.01/mkisofs/joliet.c	2006-10-28 16:59:33.000000000 +0200
@@ -90,6 +90,11 @@ static	char sccsid[] =
 #include <schily/unls.h>	/* For UNICODE translation */
 #include <schily/schily.h>
 
+#ifdef USE_ICONV
+#include <iconv.h>
+#include <errno.h>
+#endif
+
 static Uint	jpath_table_index;
 static struct directory **jpathlist;
 static int	next_jpath_index = 1;
@@ -103,13 +108,23 @@ static	char	ucs_codes[] = {
 };
 
 #ifdef	UDF
-	void	convert_to_unicode	__PR((unsigned char *buffer,
+#	ifdef USE_ICONV
+	size_t
+#	else
+	void
+#	endif
+		convert_to_unicode	__PR((unsigned char *buffer,
 		int size, char *source, struct unls_table *inls));
-	int	joliet_strlen		__PR((const char *string));
+	int	joliet_strlen		__PR((const char *string, struct unls_table *inls));
 #else
-static void	convert_to_unicode	__PR((unsigned char *buffer,
+#	ifdef USE_ICONV
+	static size_t
+#	else
+	static void
+#endif
+		convert_to_unicode	__PR((unsigned char *buffer,
 		int size, char *source, struct unls_table *inls));
-static int	joliet_strlen		__PR((const char *string));
+static int	joliet_strlen		__PR((const char *string, struct unls_table *inls));
 #endif
 static void	get_joliet_vol_desc	__PR((struct iso_primary_descriptor *jvol_desc));
 static void	assign_joliet_directory_addresses __PR((struct directory *node));
@@ -161,6 +176,20 @@ conv_charset(c, inls, onls)
 	if (inls == onls)
 		return (c);
 
+#ifdef USE_ICONV
+	if(inls->unls_cs2uni == NULL || onls->unls_uni2cs == NULL) {
+		/*
+		 * This shouldn't be reached
+		 */
+		static BOOL iconv_warned = FALSE;
+		if(!iconv_warned) {
+			error("Warning: Iconv conversion not supported in conv_charset.\n");
+			iconv_warned = TRUE;
+		}
+		return (c);
+	}
+#endif
+
 	/* get high and low UNICODE bytes */
 	uh = inls->unls_cs2uni[c].unls_high;
 	ul = inls->unls_cs2uni[c].unls_low;
@@ -186,10 +215,18 @@ conv_charset(c, inls, onls)
  *
  * Notes:
  */
-#ifdef	UDF
-void
+#ifdef USE_ICONV
+#	if	UDF
+size_t
+#	else
+static size_t
+#	endif
 #else
+#	if	UDF
+void
+#	else
 static void
+#	endif
 #endif
 convert_to_unicode(buffer, size, source, inls)
 	unsigned char	*buffer;
@@ -216,6 +253,51 @@ convert_to_unicode(buffer, size, source,
 		tmpbuf = (Uchar *) source;
 	}
 
+#ifdef USE_ICONV
+	if (inls->iconv_d && inls->unls_cs2uni==NULL &&
+			inls->unls_uni2cs==NULL) {
+		char *inptr = tmpbuf;
+		char *outptr = buffer;
+		size_t inleft = strlen(tmpbuf);
+		size_t inlen = inleft;
+		size_t outleft = size;
+
+		iconv(inls->iconv_d, NULL, NULL, NULL, NULL);
+		if(iconv(inls->iconv_d, &inptr, &inleft, &outptr, &outleft) ==
+				(size_t)-1 && errno == EILSEQ) {
+			fprintf(stderr, "Incorrectly encoded string (%s) "
+				"encountered.\nPossibly creating an invalid "
+				"Joliet extension. Aborting.\n", source);
+			exit(1);
+		}
+
+	  	for (i = 0; (i + 1) < size - outleft; i += 2) {	/* Size may be odd!!!*/
+			if (buffer[i]=='\0') {
+				switch (buffer[i+1]) {   /* Invalid characters for Joliet */
+					case '*':
+					case '/':
+					case ':':
+					case ';':
+					case '?':
+					case '\\':
+						buffer[i+1]='_';
+					default:
+						if (buffer[i+1] == 0x7f ||
+							    buffer[i+1] < 0x20)
+							buffer[i+1]='_';
+				}
+			}
+		}
+		if (size & 1) {	/* beautification */
+	  		buffer[size - 1] = 0;
+		}
+		if (source == NULL) {
+			free(tmpbuf);
+		}
+		return (inlen - inleft);
+	}
+#endif
+
 	/*
 	 * Now start copying characters.  If the size was specified to be 0,
 	 * then assume the input was 0 terminated.
@@ -271,6 +353,9 @@ convert_to_unicode(buffer, size, source,
 	if (source == NULL) {
 		free(tmpbuf);
 	}
+#ifdef USE_ICONV
+	return j;
+#endif
 }
 
 /*
@@ -287,12 +372,50 @@ int
 #else
 static int
 #endif
-joliet_strlen(string)
+joliet_strlen(string, inls)
 	const char	*string;
+	struct unls_table *inls;
 {
 	int		rtn;
 
+#ifdef USE_ICONV
+	if (inls->iconv_d && inls->unls_cs2uni==NULL &&
+			inls->unls_uni2cs==NULL) {
+		/*
+		 * we const-cast since we're sure iconv won't change
+		 * the string itself
+		 */
+		char *string_ptr = (char *)string;
+		size_t string_len = strlen(string);
+
+		/*
+		 * iconv has no way of finding out the required size
+		 * in the target
+		 */
+
+		char *tmp, *tmp_ptr;
+		/* we assume that the maximum length is 2 * jlen */
+		size_t tmp_len = (size_t)jlen * 2 + 1;
+		tmp = e_malloc(tmp_len);
+		tmp_ptr = tmp;
+
+		iconv(inls->iconv_d, NULL, NULL, NULL, NULL);
+		iconv(inls->iconv_d, &string_ptr, &string_len, &tmp_ptr,
+			&tmp_len);
+
+		/*
+		 * iconv advanced the tmp pointer with as many chars
+		 * as it has written to it, so we add up the delta
+		 */
+		rtn = (tmp_ptr - tmp);
+
+		free(tmp);
+	} else {
+		rtn = strlen(string) << 1;
+	}
+#else
 	rtn = strlen(string) << 1;
+#endif
 
 	/*
 	 * We do clamp the maximum length of a Joliet string to be the
@@ -481,16 +604,33 @@ joliet_compare_paths(r, l)
 	/* compare the Unicode names */
 
 	while (*rpnt && *lpnt) {
+#ifdef USE_ICONV
+		size_t ri, li;
+
+		ri = convert_to_unicode(rtmp, 2, rpnt, rinls);
+		li = convert_to_unicode(ltmp, 2, lpnt, linls);
+		rpnt += ri;
+		lpnt += li;
+		if(!ri && !li)
+			return (0);
+		else if(ri && !li)
+			return (1);
+		else if(!ri && li)
+			return (-1);
+#else
 		convert_to_unicode(rtmp, 2, rpnt, rinls);
 		convert_to_unicode(ltmp, 2, lpnt, linls);
+#endif
 
 		if (a_to_u_2_byte(rtmp) < a_to_u_2_byte(ltmp))
 			return (-1);
 		if (a_to_u_2_byte(rtmp) > a_to_u_2_byte(ltmp))
 			return (1);
 
+#ifndef USE_ICONV
 		rpnt++;
 		lpnt++;
+#endif
 	}
 
 	if (*rpnt)
@@ -564,10 +704,10 @@ generate_joliet_path_tables()
 		}
 #ifdef APPLE_HYB
 		if (USE_MAC_NAME(de))
-			namelen = joliet_strlen(de->hfs_ent->name);
+			namelen = joliet_strlen(de->hfs_ent->name, hfs_inls);
 		else
 #endif	/* APPLE_HYB */
-			namelen = joliet_strlen(de->name);
+			namelen = joliet_strlen(de->name, in_nls);
 
 		if (dpnt == root) {
 			jpath_table_l[jpath_table_index] = 1;
@@ -712,10 +852,10 @@ generate_one_joliet_directory(dpnt, outf
 #ifdef APPLE_HYB
 		/* Use the HFS name if it exists */
 		if (USE_MAC_NAME(s_entry1))
-			cvt_len = joliet_strlen(s_entry1->hfs_ent->name);
+			cvt_len = joliet_strlen(s_entry1->hfs_ent->name, hfs_inls);
 		else
 #endif	/* APPLE_HYB */
-			cvt_len = joliet_strlen(s_entry1->name);
+			cvt_len = joliet_strlen(s_entry1->name, in_nls);
 
 		/*
 		 * Fix the record length
@@ -849,12 +989,12 @@ joliet_sort_n_finish(this_dir)
 				if (USE_MAC_NAME(s_entry))
 					/* Use the HFS name if it exists */
 					jpath_table_size +=
-						joliet_strlen(s_entry->hfs_ent->name) +
+						joliet_strlen(s_entry->hfs_ent->name, hfs_inls) +
 						offsetof(struct iso_path_table, name[0]);
 				else
 #endif	/* APPLE_HYB */
 					jpath_table_size +=
-						joliet_strlen(s_entry->name) +
+						joliet_strlen(s_entry->name, in_nls) +
 						offsetof(struct iso_path_table, name[0]);
 				if (jpath_table_size & 1) {
 					jpath_table_size++;
@@ -876,13 +1016,13 @@ joliet_sort_n_finish(this_dir)
 				/* Use the HFS name if it exists */
 				s_entry->jreclen =
 				offsetof(struct iso_directory_record, name[0])
-					+ joliet_strlen(s_entry->hfs_ent->name)
+					+ joliet_strlen(s_entry->hfs_ent->name, hfs_inls)
 					+ 1;
 			else
 #endif	/* APPLE_HYB */
 				s_entry->jreclen =
 				offsetof(struct iso_directory_record, name[0])
-					+ joliet_strlen(s_entry->name)
+					+ joliet_strlen(s_entry->name, in_nls)
 					+ 1;
 		} else {
 			/*
@@ -1024,6 +1164,9 @@ joliet_compare_dirs(rr, ll)
 #endif
 
 	while (*rpnt && *lpnt) {
+#ifdef USE_ICONV
+		size_t ri, li;
+#endif
 		if (*rpnt == ';' && *lpnt != ';')
 			return (-1);
 		if (*rpnt != ';' && *lpnt == ';')
@@ -1044,16 +1187,32 @@ joliet_compare_dirs(rr, ll)
 			return (1);
 #endif
 
+#ifdef USE_ICONV
+
+		ri = convert_to_unicode(rtmp, 2, rpnt, rinls);
+		li = convert_to_unicode(ltmp, 2, lpnt, linls);
+		rpnt += ri;
+		lpnt += li;
+		if(!ri && !li)
+			return (0);
+		else if(ri && !li)
+			return (1);
+		else if(!ri && li)
+			return (-1);
+#else
 		convert_to_unicode(rtmp, 2, rpnt, rinls);
 		convert_to_unicode(ltmp, 2, lpnt, linls);
+#endif
 
 		if (a_to_u_2_byte(rtmp) < a_to_u_2_byte(ltmp))
 			return (-1);
 		if (a_to_u_2_byte(rtmp) > a_to_u_2_byte(ltmp))
 			return (1);
 
+#ifndef USE_ICONV
 		rpnt++;
 		lpnt++;
+#endif
 	}
 	if (*rpnt)
 		return (1);
diff -Naurp cdrtools-2.01.01.orig/mkisofs/Makefile cdrtools-2.01.01/mkisofs/Makefile
--- cdrtools-2.01.01.orig/mkisofs/Makefile	2006-10-08 13:51:43.000000000 +0200
+++ cdrtools-2.01.01/mkisofs/Makefile	2006-10-28 16:59:33.000000000 +0200
@@ -33,6 +33,7 @@ CPPOPTS +=	-DAPPLE_HYB
 CPPOPTS +=	-DUDF
 CPPOPTS +=	-DDVD_VIDEO
 CPPOPTS +=	-DSORTING
+CPPOPTS +=	-DUSE_ICONV
 CPPOPTS +=	-I../libhfs_iso/
 CPPOPTS	+=	-DUSE_SCG \
 		'-DAPPID_DEFAULT="MKISOFS ISO 9660/HFS FILESYSTEM BUILDER & CDRECORD CD-R/DVD CREATOR (C) 1993 E.YOUNGDALE (C) 1997 J.PEARSON/J.SCHILLING"' \
diff -Naurp cdrtools-2.01.01.orig/mkisofs/mkisofs.c cdrtools-2.01.01/mkisofs/mkisofs.c
--- cdrtools-2.01.01.orig/mkisofs/mkisofs.c	2006-10-08 19:55:12.000000000 +0200
+++ cdrtools-2.01.01/mkisofs/mkisofs.c	2006-10-28 16:59:33.000000000 +0200
@@ -64,6 +64,11 @@ static	char sccsid[] =
 #endif
 #endif	/* no_more_needed */
 
+#ifdef USE_ICONV
+#include <locale.h>
+#include <langinfo.h>
+#endif
+
 struct directory *root = NULL;
 int		path_ind;
 
@@ -297,6 +302,10 @@ UInt32_t null_inodes = NULL_INO_MAX;
 BOOL	correct_inodes = TRUE;	/* TRUE: add a "correct inodes" fingerprint */
 BOOL	rrip112 = TRUE;		/* TRUE: create Rock Ridge V 1.12	    */
 
+#ifdef USE_ICONV
+int iconv_possible;
+#endif
+
 struct unls_table *in_nls = NULL;  /* input UNICODE conversion table */
 struct unls_table *out_nls = NULL; /* output UNICODE conversion table */
 #ifdef APPLE_HYB
@@ -1969,6 +1978,37 @@ args_ok:
 	init_unls_file(hfs_ocharset);
 #endif /* APPLE_HYB */
 
+#ifdef USE_ICONV
+	iconv_possible = !(iso9660_level >= 4 || ((ocharset &&
+		strcmp(ocharset, icharset ? icharset : "")) &&
+		use_RockRidge) || apple_ext || apple_hyb);
+
+	setlocale(LC_CTYPE, "");
+	
+  	if (icharset == NULL && iconv_possible) {
+		char *charset = nl_langinfo(CODESET);
+		/* set to detected value but only if it is not pure US-ASCII */
+		if(strcmp(charset, "ANSI_X3.4-1968") != 0)
+			icharset = charset;
+
+		if(icharset && verbose > 0)
+			fprintf(stderr, "INFO:\t"
+			"%s character encoding detected by locale settings."
+			"\n\tAssuming %s encoded filenames on source "
+			"filesystem,\n"
+			"\tuse -input-charset to override.\n",
+			icharset, icharset);
+	}
+
+	if(iconv_possible) {
+		/*
+		 * don't care if initialization fails
+		 */
+		init_unls_iconv(icharset);
+		init_unls_iconv(ocharset);
+	}
+#endif
+
 	if (icharset == NULL) {
 #if	(defined(__CYGWIN32__) || defined(__CYGWIN__) || defined(__DJGPP__)) && !defined(IS_CYGWIN_1)
 		in_nls = load_unls("cp437");
@@ -1996,6 +2036,12 @@ args_ok:
 	if (in_nls == NULL || out_nls == NULL) { /* Unknown charset specified */
 		fprintf(stderr, "Unknown charset\nKnown charsets are:\n");
 		list_unls();	/* List all known charset names */
+#ifdef USE_ICONV
+		if(!iconv_possible)
+			fprintf(stderr, "Iconv charsets cannot be used with "
+				"Apple extension, HFS, ISO9660 version 2 or\n"
+				"Rock Ridge.\n");
+#endif
 		exit(1);
 	}
 
diff -Naurp cdrtools-2.01.01.orig/mkisofs/mkisofs.h cdrtools-2.01.01/mkisofs/mkisofs.h
--- cdrtools-2.01.01.orig/mkisofs/mkisofs.h	2006-10-08 19:55:12.000000000 +0200
+++ cdrtools-2.01.01/mkisofs/mkisofs.h	2006-10-28 16:59:33.000000000 +0200
@@ -513,9 +513,14 @@ extern int get_session_start __PR((int *
 
 /* joliet.c */
 #ifdef	UDF
+#	ifdef USE_ICONV
+extern	size_t	convert_to_unicode	__PR((unsigned char *buffer,
+			int size, char *source, struct unls_table *inls));
+#	else
 extern	void	convert_to_unicode	__PR((unsigned char *buffer,
 			int size, char *source, struct unls_table *inls));
-extern	int	joliet_strlen		__PR((const char *string));
+#	endif
+extern	int joliet_strlen		__PR((const char *string, struct unls_table *inls));
 #endif
 extern unsigned char conv_charset __PR((unsigned char, struct unls_table *,
 				struct unls_table *));
diff -Naurp cdrtools-2.01.01.orig/mkisofs/udf.c cdrtools-2.01.01/mkisofs/udf.c
--- cdrtools-2.01.01.orig/mkisofs/udf.c	2006-10-08 15:49:56.000000000 +0200
+++ cdrtools-2.01.01/mkisofs/udf.c	2006-10-28 16:59:33.000000000 +0200
@@ -439,7 +439,7 @@ set_ostaunicode(dst, dst_size, src)
 	int i;
 	int expanded_length;
 
-	expanded_length = joliet_strlen(src);
+	expanded_length = joliet_strlen(src, in_nls);
 	if (expanded_length > 1024)
 		expanded_length = 1024;
 	if (expanded_length > (dst_size-1)*2)