summaryrefslogtreecommitdiff
path: root/contrib/idn/mdnkit/doc/en/spec/library.html
blob: b990d54da5bd056459ad7a6958c7cb9b6c1ab3cc (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
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
<!doctype html public "-//IETF//DTD HTML 2.0//EN">
<!-- $Id: library.html,v 1.1 2001/03/05 12:58:02 tale Exp $ -->
<html>

<head>
<title>MDN libarary specification</title>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
</head>

<body>
<h1>MDN Library</h1>

<ul>
<li><a href="#func-overview">@\Tv</a>
<li><a href="#func-overview">Function Overview</a>
<li><a href="#module-list">W[ꗗ</a>
<li><a href="#module-list">Module List</a>
<li><a href="#module-desc">W[ڍ</a>
<li><a href="#module-desc">Details of Modules</a>
</ul>

<hr>

<h2><a name="func-overview">@\Tv</a></h2>
<h2><a name="func-overview">Function Overview</a></h2>

<p>MDN Cu (libmdn) ͑hC̕ϊɊւȅ
郂W[̏WłB̃Cu͈ȉ̂悤ȋ@\
񋟂܂B<br>
The MDN library (libmdn) is a group of modules that provide various processing with respect to multilingual domain name conversion. This library provides the following features.

<ul>
<li>GR[fBO (R[hZbg) ϊ <br>
Encoding (code set) conversion
<li>̐K<br>
Normalization of character strings
<li>DNS bZ[W̉́Ađgݗ<br>
Analysis and reassembly of DNS messages
<li>ZLD (Zero Level Domain) ̃}b`OA폜Alj<br>
Matching, removal and addition of ZLD (Zero Level Domain)
<li>[JGR[fBO̔<br>
Local encoding identification
<li>NCAgpݒt@C̓ǂݍ<br>
Loading of client configuration files


<h3>GR[fBO (R[hZbg) ϊ</h3>
<h3>Encoding (code set) conversion</h3>

<p>̃GR[fBOϊǍʂԂ܂B
MDN Cu̓ł́Aׂ͂ UTF-8 GR[fBOłƂ
舵܂BŁÃW[<br>
Converts character string encoding and returns the result.
Inside the MDN library, character strings are all handled as UTF-8 encoding. This module supports the following conversions.
<ul>
<li>GR[fBO UTF-8 ւ̕ϊ<br>
Conversion from certain encoding methods to UTF-8
<li>UTF-8 炠GR[fBOւ̕ϊ<br>
Conversion from UTF-8 to certain encoding methods
</ul>
T|[g܂B

</ul>

<p>GR[fBO͑傫āA2ނ܂B<br>
Encoding is roughly divided into the following two types.
<ul>
<li>AvP[VgpGR[fBO (VtgJISAEUC )<br>
Encoding used by applications (shift JIS, EUC, etc.)
<li>hCŎgp邽߂ɃfUCꂽʂȃGR[fBO
(UTF-5ARACE )<br>
Special encoding designed to be used for multilingual domain names
(UTF-5ARACE etc.)
</ul>
<p>̃W[ł͑O҂̃GR[fBOϊ̂߂
<em>iconv()</em> [eBeBgpA҂̃GR[fBOϊ̂߂ɂ
Ǝ̕ϊ֐ĎgpĂ܂B<br>
This module uses the <em>iconv()</em> utility for the first encoding conversion process and implements a unique conversion function for the latter encoding conversion.

<p>

<h3>̐K</h3>
<h3>Normalization of character strings</h3>

<p>^ꂽ𐳋K܂BWł͎ɂ鐳KT|[g܂B<br>
Normalizes given character strings. The following standard normalization functions are supported.
<ul>
<li>ASCII ̏啶ϊ
<br>Converts lowercase ASCII to uppercase ASCII
<li>ASCII ̑啶ϊ
<br>Converts uppercase ASCII to lowercase ASCII
<li>UnicodeData.txt ɏ]啶ϊ<br>
 Converts lowercase to uppercase as specified in UnicodeData.txt
<li>UnicodeData.txt ɏ]啶ϊ<br>
 Converts uppercase to lowercase as specified in UnicodeData.txt
<li>Unicode Normalization Form C
<br>Unicode Normalization Form C
<li>Unicode Normalization Form KC
<br>Unicode Normalization Form KC
<li>{̔pȁSpJ^Jiϊ<br>
 Converts single-byte Japanese katakana to double-byte katakana
<li>Sp}CiXLpnCtϊ<br>
 Converts double-byte minus symbols to single-byte hyphens
<li>_(B)ASpsIh(D)sIh(.)ϊ
<br> Converts Japanese periods (B) and double-byte periods (D) to periods (.)
</ul>

<br>

<h3>DNS bZ[W̉́Ađgݗ<br>
 Analysis and assembly of DNS messages</h3>

<p>DNS vLVT[o (dnsproxy) ł́ANCAg瑗Ă DNS
bZ[WɊ܂܂hCɑ΂ăGR[fBOϊ␳KsA
̌ʂ DNS T[oɑ܂B̂߂Ɉȉ̋@\񋟂܂B<br>
In the DNS proxy server (dnsproxy), encoded domain names included in DNS messages sent from the client are converted and normalized and the result is sent to the DNS server. This process is comprised of the following functions:
<ul>
<li>DNSbZ[W͂AhCo<br>
 Analyzes DNS messages and extracts domain names
<li>ϊhCpDNSbZ[Wč\<br>
 Re-constructs DNS messages using converted domain names
</ul>

<br>

<h3>ZLD (Zero Level Domain) ̃}b`OA폜Alj<br>
 Matching, removal and addition of ZLD (Zero Level Domain)</h3>

<p>hCʂ邽߂ ZLD KvƂ̂߂ɁAZLD 
ւȉ̋@\񋟂܂B<br>
To identify multilingual domain names, the following ZLD-related functions are provided:
<ul>
<li> ZLD ̒AhCɃ}b`̂T<br>
 Of the multiple number of ZLDs, finds the one that matches the domain name
<li>hC ZLD 폜<br>
 Removes the ZLD portion from the domain name
<li>hC ZLD lj<br>
 Adds ZLD to the domain name
</ul>

<br>

<h3>[JGR[fBO̔<br>
 Local encoding identification</h3>

<p>AvP[VvOgpĂ郍[JGR[fBO
(R[hZbg) ʂ܂Bʂ͊{Iɂ̓AvP[ṼP[
𗘗p܂A‹ϐŎw肷邱Ƃ”\ɂȂĂ܂B<br>
Automatically identifies the local encoding (code set) used by the application program. Basically, the application locale information is used, though the local encoding (code set) can also be specified using an environmental variable.

<p>

<h3>NCAgpݒt@C̓ǂݍ<br>
 Loading of client configuration file</h3>

<p>AvP[VɃN郊]oCuŃGR[fBO
ϊ␳KsꍇAgpGR[fBO␳K
ݒt@CɋLq܂B̃t@Cǂݍދ@\񋟂܂B<br>
When the resolver library linked by the application is used to perform conversion or normalization, the encoding and normalization method to be used is described in the configuration file. A function is provided to load this file.
<p>
<hr>
<h2><a name="module-list">W[ꗗ<br>
 Module list</a></h2>

<p>MDN Cu͈ȉ̃W[\܂B<br>
The MDN library consists of the following modules.

<dl>
<dt><a href="#brace">brace W[<br>brace module</a>
  <dd>hC̃GR[fBÖ‚ƂĒĂĂ BRACE
  GR[fBO̕ϊW[<br>
 Conversion module for the proposed BRACE encoding domain name encoding method
<dt><a href="#converter">converter module</a>
  <dd>̃GR[fBO(R[hZbg)̕ϊW[<br>
 Conversion module for character string encoding (code set)
<dt><a href="#debug">debug module</a>
  <dd>fobOpo͂̂߂̃[eBeBW[<br>
 Utility module for debug output
<dt><a href="#dn">dn module</a>
  <dd>DNS bZ[W̃hC̓WJEksW[<br>
 Extraction/compression module for domain names inside DNS messages
<dt><a href="#lace">lace module</a>
  <dd>hC̃GR[fBÖ‚ƂĒĂĂ LACE
  GR[fBO̕ϊW[<br>
 Conversion module for the proposed LACE encoding domain name encoding method
<dt><a href="#localencoding">localencoding module</a>
  <dd>AvP[V̎gpĂGR[fBO𐄑郂W[<br>
 Guesses which encoding is used by the application
<dt><a href="#log">log module</a>
  <dd>MDN CũȌo͏𐧌䂷郂W[<br>
 Controls MDN library log output processing
<dt><a href="#msgheader">msgheader module</a>
  <dd>DNS bZ[W̃wb_̉̓W[<br>
 Analyzes the header of the DNS message
<dt><a href="#msgtrans">msgtrans module </a>
  <dd>DNS vLVT[oł DNS bZ[W̕ϊs߂̃W[<br>
 Converts the DNS message at the DNS proxy server
<dt><a href="#normalizer">normalizer module</a>
  <dd>̐KsW[<br>
 Normalizes character strings
<dt><a href="#race">race module</a>
  <dd>hC̃GR[fBÖ‚ƂĒĂĂ RACE
  GR[fBO̕ϊW[<br>
 Conversion module for proposed RACE domain name encoding method
<dt><a href="#res">res module</a>
  <dd>]oCuA邢̓AvP[VŃhC
  GR[fBOϊ␳Ks߂̃C^tF[X񋟂郂W[<br>
 Provides an interface to perform encoding conversion or normalization of domain names by the resolver library or application
<dt><a href="#resconf">resconf module</a>
  <dd>]oCuA邢̓AvP[VŃhC
  GR[fBOϊ␳Ksۂ̐ݒt@Cǂݍނ߂̃W[<br>
 Loads the configuration file used by the resolver library or application during encoding conversion and normalization of domain names
<dt><a href="#result">result module</a>
  <dd>Cůe֐ԂUgR[hW[<br>
 Handles the result code returned by each library function
<dt><a href="#selectiveencode">selectiveencode module</a>
  <dd>eLXg̒ASCII܂ރhCToW[<br>
 Finds domain names that include non-ASCII characters
<dt><a href="#strhash">strhash module</a>
  <dd>L[ƂnbV\郂W[<br>
 Implements a hash table that uses character strings as keys
<dt><a href="#translator">translator module</a>
  <dd>^ꂽp[^ɏ]ăhCϊ郂W[<br>
 Converts domain name according to the specified parameters
<dt><a href="#unicode">unicode module</a>
  <dd>Unicode ̊e핶擾郂W[<br>
 Obtains various Unicode character properties
<dt><a href="#unormalize">unormalize module</a>
  <dd>Unicode Œ`ĂW̐KsW[<br>
 Performs standard normalization defined by Unicode
<dt><a href="#utf5">utf5 module</a>
  <dd>hC̃GR[fBÖ‚ƂĒĂĂ UTF-5
  ̊{sW[<br>
 Performs basic processing for the proposed UTF-5 domain name encoding method
<dt><a href="#utf8">utf8 module</a>
  <dd>UTF-8 GR[fBO̊{sW[<br>
 Performs basic processing of UTF-8 encoding character strings
<dt><a href="#util">util module</a>
  <dd>̃W[Ŏg鋤p֐񋟂郂W[<br>
 Provides common functions used by other modules
<dt><a href="#ZLDrule">ZLDrule module</a>
  <dd>hC ZLD Ƃ̃}b`OsW[<br>
 Matches domain names and ZLD
</dl>

<p>ȉɃW[̌Ăяo֌W}܂BقƂǂׂĂ
W[ĂяoĂ debug W[ log W[A܂
p֐[߂ util W[͊Ă܂B<br>
The following diagram shows the invoking relationship of modules. debug and log modules called by most modules and util modules that store common functions are omitted in the diagram.

<blockquote>
<img src="img/libmdn_callgraph.jpg" alt="libmdn module graph">
</blockquote>

<hr>

<h2><a name="module-desc">W[ڍ <br>
Details of Modules</a></h2>

<p>MDN CuɊ܂܂邷ׂẴW[ɂ‚āA̎dlLq
܂B܂eW[ŋʂɎgpA֐̃^[lɂ‚
ƁAW[ɏڍׂ܂B<br>
The specifications of all modules included in MDN library are explained below.
First, return values of functions commonly used by the modules are explained and then each module is discussed in detail.

<hr>

<h3><a name="mdn_result_t">API֐̃^[l<br>
 Values returned by API functions</a></h3>

<p>MDNCûقƂǑSĂAPI֐́A^[lƂ
񋓌^ł<em>mdn_result_t</em> ^̒lԂ܂Bl̈ꗗƂ̈Ӗ
܂B<br>
Almost all API functions of the MDN library return values of <em>mdn_result_t</em>, which is an enumeration type value. The values and their meanings are explained below. <br>

<dl>
<dt><tt>mdn_success</tt>
  <dd>Ƃ܂B<br>
 Processing was successful.
<dt><tt>mdn_notfound</tt>
  <dd>ȂǂɂāA‚ȂƂ܂B<br>
The target of search processing could not be found.
<dt><tt>mdn_invalid_encoding</tt>
  <dd>GR[fBOϊɂāA͂ꂽ̃GR[fBOԈĂ邱Ƃ܂B<br>
Incorrect conversion of encoded input character string.
<dt><tt>mdn_invalid_syntax</tt>
  <dd>t@CȂǂ̏ɊԈႢ邱Ƃ܂B<br>
Incorrect file format.
<dt><tt>mdn_invalid_name</tt>
  <dd>w肳ꂽOԈĂ邱Ƃ܂B<br>
 Specified name is incorrect.
<dt><tt>mdn_invalid_message</tt>
  <dd>͂ꂽDNSbZ[WȂƂ܂B <br>
Entered DNS message is incorrect.
<dt><tt>mdn_buffer_overflow</tt>
  <dd>ʂi[obt@̑傫ȂƂ܂B<br>
 Insufficient buffer to store result.<dt><tt>mdn_noentry</tt>
  <dd>w肳ꂽڂ݂ȂƂ܂B<br>
 Specified item does not exist.
<dt><tt>mdn_nomemory</tt>
  <dd>̃AP[VɎsƂ܂B <br>
Memory allocation failed.
<dt><tt>mdn_nofile</tt>
  <dd>w肳ꂽt@C݂ȂƂ܂B <br>Specified file does not exist.
<dt><tt>mdn_nomapping</tt>
  <dd>̃GR[fBO(R[hZbg)ϊہAϊ^[Qbg̕WɊ܂܂Ȃ (‚܂萳ϊłȂ) Ƃ܂B<br>
Conversion could not be performed correctly because a character in the encoded character string (code set) does not exist in the target conversion character set.
<dt><tt>mdn_context_required</tt>
  <dd>̑啶ϊ̍ۂɁAϊsɂ͕񂪕Kvł邱Ƃ܂B<br>
Indicates that context information is required to correctly convert uppercase characters to lowercase characters.
<dt><tt>mdn_failure</tt>
  <dd>L̂ɂĂ͂܂ȂG[Ƃ܂B<br>
Indicates that an error occurred that does not fall into any of the above categories.
</dl>

<hr>

<h3><a name="brace">brace W[ <br>
brace module</a></h3>

<p>brace W[́AhC̃GR[fBÖ‚ƂĒĂĂ<a href="../../reference/draft/draft-ietf-idn-brace-00.txt">BRACE GR[fBO</a>UTF-8Ƃ̊Ԃ̕ϊsW[łB̃W[<a href="#converter">converter W[</a>̉ʃW[ƂĎĂAAvP[ṼW[𒼐ڌĂяoƂ͂܂B<a href="#converter">converter W[</a>ɑ΂<tt>BRACE</tt> GR[fBOƂ̕ϊvƁÃW[ԐړIɌĂяo邱ƂɂȂ܂B<br>
The brace module performs conversion between UTF-8 and the proposed <a href="../../reference/draft/draft-ietf-idn-brace-00.txt">BRACE encoding</a> of multilingual domain names. This module is implemented as a low-order <a href="#converter">converter module</a>, and is not directly called by the application.
When <a href="#converter">converter module</a> is requested in association with BRACE encoding conversion, this module is indirectly called.

<p>ȉɃW[̒񋟂API֐܂B<br>
This module provides the following API functions.

<dl>

<dt><a name="mdn__brace_open">mdn__brace_open</a>
<dd>
<pre>
mdn_result_t
mdn__brace_open(mdn_converter_t ctx, mdn_converter_dir_t dir)
</pre>
<p>BRACEGR[fBOƂ̕ϊI[v܂Bۂɂ͉܂B<br>
Opens conversion context used for BRACE encoding. Actually, this does not do anything.
<p> <tt>mdn_success</tt>Ԃ܂B<br>
Always returns <tt>mdn_success</tt>.
<p>

<dt><a name="mdn__brace_close">mdn__brace_close</a>
<dd>
<pre>
mdn_result_t
mdn__brace_close(mdn_converter_t ctx, mdn_converter_dir_t dir)
</pre>
<p>BRACEGR[fBOƂ̕ϊN[Y܂Bۂɂ͉܂B<br>
Closes conversion context used for BRACE encoding. Actually, this does not do anything.
<p> <tt>mdn_success</tt>Ԃ܂B
<br>Always returns <tt>mdn_success</tt>.
<p>

<dt><a name="mdn__brace_convert">mdn__brace_convert</a>
<dd>
<pre>
mdn_result_t
mdn__brace_convert(mdn_converter_t ctx, mdn_converter_dir_t dir,
	const char *from, char *to, size_t tolen)
</pre>
<p>BRACEGR[hꂽUTF-8GR[hꂽ̑ݕϊ
s܂B͕ <var>from</var> ϊAʂ <var>to</var> 
<var>tolen</var> Ŏw肳̈ɏ݂܂B<var>dir</var> <tt>mdn_converter_l2u</tt>ȂBRACEGR[fBOUTF-8GR[fBOցA<tt>mdn_converter_u2l</tt>ȂUTF-8GR[fBOBRACEGR[fBOւ̕ϊƂȂ܂B<br>
Performs bidirectional conversion of BRACE and UTF-8 encoded character strings.
The <var>from</var> input character string is converted and the result is written in the area specified by <var>to</var> and <var>tolen</var>.
When <var>dir</var> is <tt>mdn_converter_l2u</tt>, BRACE strings are converted to UTF-8 encoding and when <var>dir</var> is <tt>mdn_converter_u2l</tt>, UTF-8 strings are converted to BRACE encoding.
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_buffer_overflow</tt>
<br><tt>mdn_invalid_encoding</tt>
<br><tt>mdn_nomemory</tt>

</dl>

<hr>

<h3><a name="converter">converter W[ <br>
converter module</a></h3>

<p>converter W[́ÃGR[fBO(R[hZbg)
ϊ܂BMDN Cu͓ UTF-8 GR[fBO̕
gp邽߁ÃW[̓[JGR[fBO UTF-8 Ƃ
Ԃ̑ݕϊs܂B<br>
converter module converts character string encoding (code set). Because the MDN library uses UTF-8 character strings for internal processing, this module performs bidirectional conversion between the local encoding method and UTF-8.

<p>݃T|[gĂGR[fBO͎̒ʂł <br>
Support is currently provided for the following encoding methods.
<ul>
<li><em>iconv()</em> T|[gĂGR[fBO<br>
    <em>iconv()</em> encoding support<br>
<br>
    iconv() Ƃ͔ėpIȃR[hZbgϊ@\񋟂֐ŁA
    ̊֐T|[gGR[fBOT|[g܂B
    iconv() T|[gGR[fBO͎ˑȂ̂ŁA
    ̓Iɂǂ̃GR[fBOgp”\Ȃ̂ iconv() 
    hLgB<br>
    The iconv() function provides general code set conversion functions and encoding support. The encoding methods supported by iconv() are implementation-dependent; in that regard, refer to the documentation included with iconv() for information on which encoding is actually available.
<li><tt>UTF-5</tt><br>
    hC̃GR[fBO@ƂĒĂĂ̂łB
    ڂ
    <a href="../../reference/draft/draft-jseng-utf5-01.txt">draft-jseng-utf5-01.txt</a>
    B<br>
Proposed multilingual domain name encoding method. For details, refer to
    <a href="../../reference/draft/draft-jseng-utf5-01.txt">draft-jseng-utf5-01.txt</a>

<li><tt>RACE</tt><br>
    hC̃GR[fBO@ƂĒĂĂ̂łB
    ڂ
    <a href="../../reference/draft/draft-ietf-idn-race-02.txt">draft-ietf-idn-race-02.txt</a>
    B<br>
Proposed multilingual domain name encoding method. For details, refer to
    <a href="../../reference/draft/draft-ietf-idn-race-02.txt">draft-ietf-idn-race-02.txt</a>

<li><tt>BRACE</tt><br>
    hC̃GR[fBO@ƂĒĂĂ̂łB
    ڂ
    <a href="../../reference/draft/draft-ietf-idn-brace-00.txt">draft-ietf-idn-brace-00.txt</a>
    B<br>
Proposed multilingual domain name encoding method. For details, refer to
    <a href="../../reference/draft/draft-ietf-idn-brace-00.txt">draft-ietf-idn-brace-00.txt</a>

<li><tt>LACE</tt><br>
    hC̃GR[fBO@ƂĒĂĂ̂łB
    ڂ
    <a href="../../reference/draft/draft-ietf-idn-lace-00.txt">draft-ietf-idn-lace-00.txt</a>
    B<br>
Proposed multilingual domain name encoding method. For details, refer to
    <a href="../../reference/draft/draft-ietf-idn-lace-00.txt">draft-ietf-idn-lace-00.txt</a>

</ul>

<p>܂Aconverter W[̓hC̃GR[fBOϊ̂߂
ʂɐ݌vꂽ̂ŁAʓIȃGR[fBOϊɂ͕KK܂B
Ⴆ UTF-5ARACEABRACEALACE GR[fBO̓hC
؂蕶łsIhʂɈ܂B<br>
The converter module is specially designed for encoding conversion of domain names and is not suitable for general encoding conversion.
For example, UTF-5, RACE, BRACE, and LACE encoding provide special handling of the delimiting periods used in domain names.

<p>converter W[́uR[hϊReLXgvƂTOp܂B
GR[fBO UTF-8 Ƃ̑ݕϊsɂ́A܂
̃GR[fBÕR[hϊReLXg쐬܂Bۂ
R[hϊɂ̓GR[fBO𒼐ڎw肷̂ł͂ȂA
R[hϊReLXgw肵܂BR[hϊReLXǧ^
<em>mdn_converter_t</em> ^łÂ悤 opaque ^ƂĒ`Ă܂B<br>
The converter module employs the "code conversion context" concept.
When perform bidirectional conversion between a specific encoding method and UTF-8, first the code conversion context of that encoding is created. For actual code conversion, the encoding is not directly specified; instead this code conversion context is specified. The code conversion context is <em>mdn_converter_t</em> and is defined as the following opaque type.
<blockquote>
<pre>
typedef struct mdn_converter *mdn_converter_t;
</pre>
</blockquote>

<p>ȉɃW[̒񋟂API֐܂B<br>
This module provides the following API functions.

<dl>

<dt><a name="mdn_converter_initialize">mdn_converter_initialize</a>
<dd>
<pre>
mdn_result_t
mdn_converter_initialize(void)
</pre>
<p>W[̏s܂B{W[̑API֐ĂԑO
 KĂяoĂB<br>
Initializes the module. This function is always called before calling other API functions of this module.
<p>Ԃl<tt>mdn_success</tt>A<tt>mdn_nomemory</tt>̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_nomemory</tt>
<p>

<dt><a name="mdn_converter_create">mdn_converter_create</a>
<dd>
<pre>
mdn_result_t
mdn_converter_create(const char *name, mdn_converter_t *ctxp,
        int delayedopen)
</pre>
<p><var>name</var> Ŏw肳郍[JGR[fBO UTF-8 Ƃ̊Ԃ
R[hϊReLXg쐬AA<var>ctxp</var> ̎ẅ
i[܂B<br>
Creates the code conversion context used for conversion between the local encoding specified by <var>name</var> and UTF-8, then initializes and stores it in the area specified by <var>ctxp</var>.
<p>[JGR[fBOƂāÂ݂Ƃ
<tt>UTF-5</tt>A<tt>RACE</tt>A<tt>BRACE</tt>A<tt>LACE</tt>
̕ϊ@\pӂĂ܂BȊÕGR[fBOw肳ꂽꍇɂ́AVXe̒񋟂<em>iconv()</em> [eBeBpĕϊs܂B
̏ꍇÅ֐̌Ăяo<em>iconv_open()</em> ̌Ăяos܂A
<var>delayedopen</var> ^ȂΎۂɕ̕ϊs܂
<em>iconv_open()</em> ̌Ăяox܂B<br>
Currently provides <tt>UTF-5</tt>, <tt>RACE</tt>, <tt>BRACE</tt>, and <tt>LACE</tt> conversion functions.
For encoding methods other than those listed above, conversion is performed using the <em>iconv()</em> utility provided with the system.
In such a case, when this function is invoked <em>iconv_open()</em> is called. When <var>delayedopen</var> is true, calling of <em>iconv_open()</em> is delayed until the character string is actually converted.
<p>܂<a href="#mdn_converter_register"><em>mdn_converter_register</em></a>
pĐVȃ[JGR[fBOlj邱Ƃ”\łB<br>
In addition, <a href="#mdn_converter_register"><em>mdn_converter_register</em></a> can be also used to add new local encoding methods.
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_invalid_name</tt>
<br><tt>mdn_nomemory</tt>
<br><tt>mdn_failure</tt>
<p>

<dt><a name="mdn_converter_destroy">mdn_converter_destroy</a>
<dd>
<pre>
void
mdn_converter_destroy(mdn_converter_t ctx)
</pre>
<p><a href="#mdn_converter_create"><em>mdn_converter_create</em></a> 
쐬R[hϊReLXg폜Amۂ܂B<br>
Deletes the code conversion context created by <a href="#mdn_converter_create"><em>mdn_converter_create</em></a> and releases the allocated memory.
<p>

<dt><a name="mdn_converter_convert">mdn_converter_convert</a>
<dd>
<pre>
mdn_result_t
mdn_converter_convert(mdn_converter_t ctx,
	mdn_converter_dir_t dir, const char *from,
	char *to, size_t tolen)
</pre>
<p><a href="#mdn_converter_create"><em>mdn_converter_create</em></a> ō쐬R[hϊReLXgpĕ <var>from</var> R[hϊAʂ <var>to</var> Ɋi[܂B<var>tolen</var>  <var>to</var> ̒łB
<var>dir</var> ͕ϊ̎̕wŁA<br>
Uses the code conversion context created by <a href="#mdn_converter_create"><em>mdn_converter_create</em></a> to perform code conversion of character strings and stores the result in <var>to</var>.
<var>tolen</var> is the length of <var>to</var>. <var>dir</var> is used to specify the direction of conversion.
<ul>
<li><tt>mdn_converter_l2u</tt>Ȃ烍[JGR[fBO UTF-8 ւ̕ϊ <br>
<tt>mdn_converter_l2u</tt> specifies the conversion method used to convert from local encoding to UTF-8.
<li><tt>mdn_converter_u2l</tt>Ȃ UTF-8 烍[JGR[fBOւ̕ϊ <br>
<tt>mdn_converter_u2l</tt> the conversion method used to convert from UTF-8 to the local encoding method.
</ul>
ƂȂ܂B

<p><tt>ISO-2022-JP</tt>̂悤ɏԂƒGR[fBOgpꍇA
<em>iconv()</em> ƈقȂÅ֐̌ĂяoԂŏԂ͕ۑ܂B
ϊ͖񏉊Ԃn܂܂B<br>
Unlike <em>iconv()</em>, when status-dependent encoding such as <tt>ISO-2022-JP</tt> is used, the status that is in effect when the function is called the first time is not maintained when this function is called the next time.
Conversion starts from the initial status each time.
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_buffer_overflow</tt>
<br><tt>mdn_invalid_encoding</tt>
<br><tt>mdn_invalid_name</tt>
<br><tt>mdn_nomemory</tt>
<br><tt>mdn_failure</tt>
<p>

<dt><a name="mdn_converter_localencoding">mdn_converter_localencoding</a>
<dd>
<pre>
char *
mdn_converter_localencoding(mdn_converter_t ctx)
</pre>
<p>R[hϊReLXg <var>ctx</var> ̃[JGR[fBO
Ԃ܂B<br>
Returns the local encoding name of the code conversion context <var>ctx</var>.
<p>

<dt><a name="mdn_converter_isasciicompatible">mdn_converter_isasciicompatible</a>
<dd>
<pre>
int
mdn_converter_isasciicompatible(mdn_converter_t ctx)
</pre>
<p>R[hϊReLXg <var>ctx</var> ̃[JGR[fBO
ASCII݊GR[fBOǂԂ܂BASCII݊GR[fBOȂ
0łȂlAłȂȂ1Ԃ܂B<br>
Returns whether or not the local encoding of the code conversion context <var>ctx</var>is ASCII-compatible. When the local encoding method is ASCII-compatible encoding, a value other than 0 is returned and if not, 1 is returned.
<p><a name="ACE">ASCII݊GR[fBO</a>
(<cite>ASCII-compatible Encoding</cite>) Ƃ́ÃGR[fBOŃGR[hꂽhCʏASCIĨhCƋʂłȂA‚܂pуnCt݂̂ō\悤ȃGR[fBÔƂŁA̓Iɂ RACE Ȃǂ܂B̃GR[fBO͈ʂɃAvP[Ṽ[JGR[fBOƂėp邱Ƃ͂܂񂪁ADNS vgRŃhC\߂̃GR[fBOƂĂ(] DNS T[oȂ̕ύXȂɎg邱Ƃ) L͎Ă̂łB<br>
<a name="ACE">ASCII-compatible encoding</a> consists of only alphenumeric characters and hyphens, meaning it is not possible to differentiate between domain names encoded using this encoding and standard ASCII domain names. Specifically, RACE encoding is of this type.
These types of encoding are not generally used for local encoding by applications but are strong candidates for the encoding used to express domain names in the DNS protocol (because conventional DNS servers can be used without modification).
<p>

<dt><a name="mdn_converter_addalias">mdn_converter_addalias</a>
<dd>
<pre>
mdn_result_t
mdn_converter_addalias(const char *alias_name, const char *real_name)
</pre>
<p>GR[fBO <var>real_name</var> ɑ΂āA<var>alias_name</var>
Ƃʖo^܂Bo^ʖ<a href="#mdn_converter_create"><em>mdn_converter_create</em></a> <var>name</var> Ɏw肷邱Ƃł܂B<br>
Used to register the alias <var>alias_name</var> for the encoding name <var>real_name</var> . Registered aliases can be specified in the var>name</var> argument of <a href="#mdn_converter_create"><em>mdn_converter_create</em></a>.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_nomemory</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_nomemory</tt>
<p>

<dt><a name="mdn_converter_aliasfile">mdn_converter_aliasfile</a>
<dd>
<pre>
mdn_result_t
mdn_converter_aliasfile(const char *path)
</pre>
<p>t@C <var>path</var> Ŏw肳t@Cǂݍ݁A̓e
]ĕʖo^܂B<br>
Loads the file specified by the <var>path</var> variable and registers the alias in accordance with the contents of the file.
<p>t@C <var>path</var> ͎̂悤ȒPȌ`̍sȂeLXgt@CłB<br>
The file <var>path</var> is a text file consisting of the following simple format.
<pre>
    ʖ     
    Alias   Formal name

</pre>
<p>܂ <tt>#</tt>Ŏn܂s̓RgƂ݂Ȃ܂B<br>
In addition, comment lines begin with <tt>#</tt>.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_nofile</tt>A
<tt>mdn_invalid_syntax</tt>A
<tt>mdn_nomemory</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_nofile</tt>
<br><tt>mdn_invalid_syntax</tt>
<br><tt>mdn_nomemory</tt>
<p>

<dt><a name="mdn_converter_resetalias">mdn_converter_resetalias</a>
<dd>
<pre>
mdn_result_t
mdn_converter_resetalias(void)
</pre>
<p><a href="#mdn_converter_addalias"><em>mdn_converter_addalias</em></a>
 <a href="#mdn_converter_aliasfile"><em>mdn_converter_aliasfile</em></a>
œo^ʖZbgAʖSo^ĂȂԂɖ߂܂B<br>
Resets aliases registered using <a href="#mdn_converter_addalias"><em>mdn_converter_addalias</em></a> or <a href="#mdn_converter_aliasfile"><em>mdn_converter_aliasfile</em></a> to the initial default status (where no aliases are registered).
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_nomemory</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_nomemory</tt>
<p>

<dt><a name="mdn_converter_register">mdn_converter_register</a>
<dd>
<pre>
mdn_result_t
mdn_converter_register(const char *name,
	mdn_converter_openproc_t open,
	mdn_converter_closeproc_t close,
	mdn_converter_convertproc_t convert,
	int ascii_compatible)
</pre>
<p><var>name</var> ƂÕ[JGR[fBO UTF-8Ƃ
Ԃ̃GR[fBOϊ@\lj܂B<var>open</var>A<var>close</var>A
<var>convert</var> ͕ϊ̏֐ւ̃|C^łB
<var>ascii_compatible</var> ɂ͂̃[JGR[fBO
ASCII݊GR[fBOȂ1AłȂ0w肵܂B<br>
Adds the encoding conversion function between the <var>name</var> local encoding method and UTF-8. <var>open</var>, <var>close</var>, and <var>convert</var> are used as pointers to processing functions such as conversion. 1 specifies <var>ascii_compatible</var> local encoding, 0 that local encoding is not ASCII compatible.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_nomemory</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt> and
<br><tt>mdn_nomemory</tt>

</dl>

<hr>

<h3><a name="debug">debug W[ <br>
debug module</a></h3>

<p>debug W[̓fobOpo͂̂߂̃[eBeBW[łB<br>
The debug module is a utility module for debug output.

<p>ȉɃW[̒񋟂API֐܂B<br>
This module provides the following API functions.

<dl>
<dt><a name="mdn_debug_hexstring">mdn_debug_hexstring</a>
<dd>
<pre>
char *
mdn_debug_hexstring(const char *s, int maxbytes)
</pre>
<p> <var>s</var> 16i\Ԃ܂B
<var>maxbytes</var> ͕\ő̒ŁA<var>s</var> 𒴂ꍇɂ
Ō <code>...</code>lj܂B<br>
Returns a hexidecimal character string of <var>s</var> length. <var>maxbytes</var> indicates the maximum length expressed and when <var>s</var> exceeds that length, <code>...</code> is appended to the string at that point.

<p>Ԃ镶͖̃̈{֐̕ێX^eBbNϐ̂̂ŁA̓e͖{֐̎̌Ăяo܂ŗLłB<br>
The memory area allocated for the returned character string is used for the static variable held by this function and is in effect until the function is called the next time.
<p>

<dt><a name="mdn_debug_xstring">mdn_debug_xstring</a>
<dd>
<pre>
char *
mdn_debug_xstring(const char *s, int maxbytes)
</pre>
<p> <var>s</var> ̒ŁAR[h128ȏ̂̂<tt>\x{HH}</tt>`
\Ԃ܂B
<var>maxbytes</var> ͕\ő̒ŁA<var>s</var> 𒴂ꍇɂ
Ō <code>...</code>lj܂B<br>
Of the <var>s</var> character strings, returns in <tt>\x{HH}</tt> format those character strings 128 bytes or larger.
<var>maxbytes</var> indicates the maximum length expressed and when <var>s</var> exceeds this, <code>...</code> is appended to the string at that point.
<p>Ԃ镶͖̃̈{֐̕ێX^eBbNϐ
̂ŁA̓e͖{֐̎̌Ăяo܂ŗLłB<br>
The memory area allocated for the returned character string is used for the static variable held by this function and is in effect until the function is called the next time.
<p>

<dt><a name="mdn_debug_hexdata">mdn_debug_hexdata</a>
<dd>
<pre>
char *
mdn_debug_hexdata(const char *s, int length, int maxlength)
</pre>
<p> <var>length</var> ̃oCg <var>s</var> 16i\Ԃ܂B<var>maxbytes</var> ͕\ő̃oCgŁA<var>length</var> 𒴂ꍇɂ͍Ō <code>...</code>lj܂B<br>
Returns the <var>length</var> of byte row <var>s</var> in hexadecimal character strings. <var>maxbytes</var> indicates the maximum length expressed and when <var>length</var> exceeds this, <code>...</code> is appended to the string at that point.
<p>Ԃ镶͖̃̈{֐̕ێX^eBbNϐ̂̂ŁA̓e͖{֐̎̌Ăяo܂ŗLłB<br>
The memory area allocated for the returned character string is used for the static variable held by this function and is in effect until the function is called the next time.
<p>

<dt><a name="mdn_debug_hexdump">mdn_debug_hexdump</a>
<dd>
<pre>
void
mdn_debug_hexdump(const char *s, int length)
</pre>
<p> <var>length</var> ̃oCg <var>s</var> 16i_vWG[o͂ɕ\܂B<br>
The standard error output is comprised of a hexidecimal dump of <var>length</var> of byte row <var>s</var>.

</dl>

<hr>

<h3><a name="dn">dn W[ dn module</a></h3>

<p>dn W[́ADNS bZ[W̃hC̓WJEksW[
łB̓]oCu<em>res_comp</em> <em>res_expand</em> 
@\񋟂܂B<br>
The dn module expands or compresses domain names in DNS messages. This provides the functional equivalent of <em>res_comp</em> and <em>res_expand</em> in the resolver library.

<p>̃W[͖{Cȗ̃W[̂ݗp邱Ƃz肵
݌vĂ܂B<br>
This module was designed under the assumption that it would only used by only other modules in the libary.

<p>hC̈k̍ۂ́AɎ<em>mdn__dn_t</em> ^̃ReLXg
gp܂B<br>
When a domain name is compressed, context information of type <em>mdn__dn_t</em> is used, as shown below:
<blockquote>
<pre>
#define MDN_DN_NPTRS	64
typedef struct {
	const unsigned char *msg;
	int cur;
	int offset[MDN_DN_NPTRS];
} mdn__dn_t;
</pre>
</blockquote>

<p>ȉɃW[̒񋟂API֐܂B<br>
This module provides the following API functions.

<dl>

<dt><a name="mdn__dn_expand">mdn__dn_expand</a>
<dd>
<pre>
mdn_result_t
mdn__dn_expand(const char *msg, size_t msglen,
	const char *compressed, char *expanded,
	size_t buflen, size_t *complenp)
</pre>
<p> <var>msglen</var> DNSbZ[W <var>msg</var> 
kꂽhC <var>compressed</var> WJA
<var>expanded</var> Ɍʂi[܂B
<var>buflen</var>  <var>expanded</var> ̑傫łB
܂A<var>compressed</var> ̒ <var>*complenp</var> Ɋi[܂B<br>
Expands the compressed domain name in DNS message <var>msg</var> of length <var>msglen</var> and stores the result in <var>expanded</var>.
<var>buflen</var> is the size of <var>expanded</var>.
Also, the length of <var>compressed</var> is stored in <var>*complenp</var>.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_buffer_overflow</tt>A
<tt>mdn_invalid_message</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_buffer_overflow</tt>
<br><tt>mdn_invalid_message</tt>
<p>

<dt><a name="mdn__dn_initcompress">mdn__dn_initcompress</a>
<dd>
<pre>
void
mdn__dn_initcompress(mdn__dn_t *ctx, const char *msg)
</pre>
<p>hCkp̃ReLXg <var>ctx</var> ܂B
̊֐<a href="#mdn__dn_compress"><em>mdn__dn_compress</em></a> ĂяoOɕKĂяoKv܂B
<var>msg</var> ͈khCi[DNSbZ[W
擪AhXłB<br>
Initializes context information <var>ctx</var> for domain name compression.
This function must be called before calling <a href="#mdn__dn_compress"><em>mdn__dn_compress</em></a>.
<var>msg</var> is the leading address in a DNS message where the compressed domain name is stored.
<p>

<dt><a name="mdn__dn_compress">mdn__dn_compress</a>
<dd>
<pre>
mdn_result_t
mdn__dn_compress(const char *name, char *sptr, size_t length,
	mdn__dn_t *ctx, size_t *complenp)
</pre>
<p><var>name</var> ̎whCk <var>sptr</var> ̎w
ꏊɊi[܂B<var>length</var>  <var>sptr</var> ̋󂫗̈̒łB
k̍ۂ́A<var>ctx</var> ɓĂȑOɈkhC̏
QƂ܂BkhC̒ <var>complenp</var> ɓƂƂɁAkɕKvȏ <var>ctx</var> ɒlj܂B<br>
Compresses the domain name indicated by <var>name</var> and stores it in the location indicated by <var>sptr</var>. <var>length</var> is the length of available space <var>sptr</var>.
When compression is performed, the previously compressed domain name information in <var>ctx</var> is referenced. The length of the compressed domain name is placed in <var>complenp</var> and also the information necessary for compression is added to <var>ctx</var>.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_buffer_overflow</tt>A
<tt>mdn_invalid_name</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_buffer_overflow</tt>
<br><tt>mdn_invalid_name</tt>

</dl>

<hr>

<h3><a name="lace">lace W[ <br>
lace module</a></h3>

<p>lace W[́AhC̃GR[fBÖ‚Ƃ
ĂĂ
<a href="../../reference/draft/draft-ietf-idn-lace-00.txt">
LACE GR[fBO</a>
UTF-8Ƃ̊Ԃ̕ϊsW[łB̃W[
<a href="#converter">converter W[</a>
ʃW[ƂĎĂA
AvP[ṼW[𒼐ڌĂяoƂ͂܂B
<a href="#converter">converter W[</a>ɑ΂
<tt>LACE</tt> GR[fBO
Ƃ̕ϊvƁÃW[ԐړIɌĂяo邱ƂɂȂ܂B<br>
The lace module performs conversion between UTF-8 and <a href="../../reference/draft/draft-ietf-idn-lace-00.txt"> the proposed </a>LACE</a> multilingual domain name encoding method. This module is implemented as a low-order <a href="#converter">converter module</a>, and is not directly called by the application.
When the <a href="#converter">converter module</a  > is requested for conversion with <tt>LACE</tt> encoding, this module is indirectly called.

<p>ȉɃW[̒񋟂API֐܂B<br>
This module provides the following API functions.

<dl>

<dt><a name="mdn__lace_open">mdn__lace_open</a>
<dd>
<pre>
mdn_result_t
mdn__lace_open(mdn_converter_t ctx, mdn_converter_dir_t dir)
</pre>
<p>LACEGR[fBOƂ̕ϊI[v܂Bۂɂ͉܂B<br>
Opens conversion context with LACE encoding. Actually, this does not do anything. 

<p> <tt>mdn_success</tt>Ԃ܂B<br>
Always returns <tt>mdn_success</tt>.
<p>

<dt><a name="mdn__lace_close">mdn__lace_close</a>
<dd>
<pre>
mdn_result_t
mdn__lace_close(mdn_converter_t ctx, mdn_converter_dir_t dir)
</pre>
<p>LACEGR[fBOƂ̕ϊN[Y܂Bۂɂ͉܂B<br>
Closes conversion context with LACE encoding. Actually, this does not do anything.
<p> <tt>mdn_success</tt>Ԃ܂B<br>
Always returns <tt>mdn_success</tt>.
<p>

<dt><a name="mdn__lace_convert">mdn__lace_convert</a>
<dd>
<pre>
mdn_result_t
mdn__lace_convert(mdn_converter_t ctx, mdn_converter_dir_t dir,
	const char *from, char *to, size_t tolen)
</pre>
<p>LACEGR[hꂽUTF-8GR[hꂽ̑ݕϊ
s܂B
͕ <var>from</var> ϊAʂ <var>to</var> 
<var>tolen</var> Ŏw肳̈ɏ݂܂B
<var>dir</var> <tt>mdn_converter_l2u</tt>Ȃ
LACEGR[fBOUTF-8GR[fBOցA<tt>mdn_converter_u2l</tt>
ȂUTF-8GR[fBOLACEGR[fBOւ̕ϊƂȂ܂B<br>
Provides bidirectional conversion between LACE character strings and UTF-8 character strings.
The <var>from</var> input character string is converted and the result is written in the area specified by <var>to</var> and <var>tolen</var>.
When <var>dir</var> is <tt>mdn_converter_l2u</tt>, LACE encoding is converted to UTF-8 encoding. When it is <tt>mdn_converter_u2l</tt>, UTF-8 encoding is converted to LACE encoding.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_buffer_overflow</tt>A
<tt>mdn_invalid_encoding</tt>A
<tt>mdn_nomemory</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_buffer_overflow</tt>
<br><tt>mdn_invalid_encoding</tt>
<br><tt>mdn_nomemory</tt>

</dl>

<hr>

<h3><a name="localencoding">localencoding W[ localencoding module</a></h3>

<p>localencoding W[̓P[𗘗pāA
AvP[V̎gpĂGR[fBO𐄑郂W[łB<br>
The localencoding module uses locale information to guess the encoding used by the application.

<p>ȉɃW[̒񋟂API֐܂B<br>
This module provides the following API functions.

<dl>

<dt><a name="mdn_localencoding_name">mdn_localencoding_name</a>
<dd>
<pre>
const char *
mdn_localencoding_name(void)
</pre>
<p>݂̃P[ɁAAvP[V̎gpĂGR[fBO
(<em><a href="#mdn_converter_create">mdn_converter_create()</a></em> ɓn
O) 𐄑ĕԂ܂B<br>
Guesses the type of encoding used by the application (the name passed to <em><a href="#mdn_converter_create">mdn_converter_create()</a></em>)and returns it based on the current locale information.
<p>́AVXe<em>nl_langinfo()</em> Ă΂𗘗pA
łȂ<em>setlocale()</em> ‹ϐ̏񂩂s܂B
҂̏ꍇɂ͕KGR[fBOƂ͌܂B<br>
To guess the type of encoding, <em>nl_langinfo()</em> is used if it is available in the the system and if not, <em>setlocale()</em> or environmental variable information is used.
In the latter case, the corrent encoding name may not be obtained.
<p>P[񂩂琳łȂꍇA̓AvP[V
P[ƈقȂGR[fBOpē삵Ăꍇ̂߂ɁA
‹ϐ <var>MDN_LOCAL_CODESET</var> `Ă΁A
AvP[ṼP[Ɋւ炸A̕ϐ̒lGR[fBOƂ
Ԃ悤ɂȂĂ܂B<br>
When <var>MDN_LOCAL_CODESET</var> environmental variable is defined in order to deal with situations in which the correct encoding cannot be guessed from the locale information or the application is operating using different encoding than that the locale, this module returns the value of that variable as the encoding name regardless of the application locale.

</dl>

<hr>

<h3><a name="log">log W[ log module</a></h3>

<p>log W[MDN CũȌo͏𐧌䂷郂W[łB
O̓ftHgł͕WG[o͂ɏo܂Anho^
ƂŁAʂ̏o͕@ɕύX邱Ƃ”\łB<br>
log module controls MDN library log output.
A standard error output log is written by default. It can, however, be changed to another output method by registering the handler.
<p>܂Oxݒ肷邱Ƃ”\łBOx͎5iK
`Ă܂B<br>
The log level can be set as well. The following five log levels are defined.
<blockquote>
<pre>
enum {
	mdn_log_level_fatal   = 0,
	mdn_log_level_error   = 1,
	mdn_log_level_warning = 2,
	mdn_log_level_info    = 3,
	mdn_log_level_trace   = 4,
	mdn_log_level_dump    = 5
};
</pre>
</blockquote>

<p>ȉɃW[̒񋟂API֐܂B<br>
This module provides the following API functions.

<dl>

<dt><a name="mdn_log_fatal">mdn_log_fatal</a>
<dd>
<pre>
void
mdn_log_fatal(const char *fmt, ...)
</pre>
<p>fatal x̃Oo͂܂B̃x́AvO̎s
s”\ł悤ȒvIȃG[̍ۂɗp܂B
<em>printf</em> Ɠ`Ŏw肵܂B<br>
Outputs a fatal level log. This level is used when a fatal error occurs that causes problems such as when program execution cannot be performed.
Arguments are specified using the same format as <em>printf</em>.
<p>

<dt><a name="mdn_log_error">mdn_log_error</a>
<dd>
<pre>
void
mdn_log_error(const char *fmt, ...)
</pre>
<p>error x̃Oo͂܂B̃x́A
vIł͂ȂG[̍ۂɗp܂B
<em>printf</em> Ɠ`Ŏw肵܂B<br>
Outputs the error level log. This level is used when an error occurs that is not fatal.
Arguments are specified using the same format as <em>printf</em>.
<p>

<dt><a name="mdn_log_warning">mdn_log_warning</a>
<dd>
<pre>
void
mdn_log_warning(const char *fmt, ...)
</pre>
<p>warning x̃Oo͂܂B̃x͌xbZ[W
\邽߂ɗp܂B
<em>printf</em> Ɠ`Ŏw肵܂B<br>
Outputs a warning level log. This level is used to display a warning message.
Arguments are specified using the same format as <em>printf</em>.
<p>

<dt><a name="mdn_log_info">mdn_log_info</a>
<dd>
<pre>
void
mdn_log_info(const char *fmt, ...)
</pre>
<p>info x̃Oo͂܂B̃x̓G[ł͂ȂA
LpƎvo͂̂ɗp܂B
<em>printf</em> Ɠ`Ŏw肵܂B<br>
Outputs info level log. This level is not used for errors but instead to output other potentially useful information.
Arguments are specified using the same format as <em>printf</em>.

<p>

<dt><a name="mdn_log_trace">mdn_log_trace</a>
<dd>
<pre>
void
mdn_log_trace(const char *fmt, ...)
</pre>
<p>trace x̃Oo͂܂B̃xAPI֐̃g[X
o͂̂ɗp܂BʂɃCũfobOړIȊO
̃x̃OL^Kv͂Ȃł傤B
<em>printf</em> Ɠ`Ŏw肵܂B<br>
Outputs the trace level log. This level is used to output API function trace information. Generally, this log does not need to be recorded for purposes other than debugging the library.
The arguments are specified using the same format as <em>printf</em>.
<p>

<dt><a name="mdn_log_dump">mdn_log_dump</a>
<dd>
<pre>
void
mdn_log_dump(const char *fmt, ...)
</pre>
<p>dump x̃Oo͂܂B̃x͂ɃfobOp
pPbgf[^_vȂǂo͂̂ɗp܂B
ʂɃCũfobOړIȊOł̃x̃OL^
Kv͂Ȃł傤B
 <em>printf</em> Ɠ`Ŏw肵܂B<br>
Outputs the dump level log. This level is used to output additional packet data dump for debugging.
Generally, this level of log does not need to be recorded for purposes other than debugging the library.
The arguments are specified using the same format as for <em>printf</em>.
<p>

<dt><a name="mdn_log_setlevel">mdn_log_setlevel</a>
<dd>
<pre>
void
mdn_log_setlevel(int level)
</pre>
<p>Oo͂̃xݒ肵܂Bݒ肵x𒴂郌x
O͏o͂܂B̊֐ŃOxݒ肵ȂꍇA
‹ϐ <tt>MDN_LOG_LEVEL</tt> ɐݒ肳ꂽlgp܂B<br>
Sets the level of log output. Logs higher than the set level are not output. When the log level is not specified with this function, the integer value set to the <tt>MDN_LOG_LEVEL</tt> environmental variable is used.
<p>

<dt><a name="mdn_log_getlevel">mdn_log_getlevel</a>
<dd>
<pre>
int
mdn_log_getlevel(void)
</pre>
<p>݂̃Oo͂̃x\l擾ĕԂ܂B<br>
Obtains and returns the integer value for the current level of log output.
<p>

<dt><a name="mdn_log_setproc">mdn_log_setproc</a>
<dd>
<pre>
void
mdn_log_setproc(mdn_log_proc_t proc)
</pre>
<p>Ȍo̓nhݒ肵܂B<var>proc</var> ̓nh֐ւ
|C^łBnhw肵ȂꍇA邢 <var>proc</var> 
NULL w肵ꍇɂ́AO͕WG[o͂ɏo͂܂B<br>
Used to set the log output handler. <var>proc</var> is a pointer to the handler function. When the handler is not specified or NULL is specified for <var>proc</var>, a standard error log is output.
<p>nȟ^ <tt>mdn_log_proc_t</tt> ͎̂悤ɒ`Ă܂B<br>
The <tt>mdn_log_proc_t</tt> handler type is defined as follows.
<blockquote>
<pre>
typedef void  (*mdn_log_proc_t)(int level, const char *msg);
</pre>
</blockquote>
<var>level</var> ɂ̓ÕxA܂ <var>msg</var> ɂ͕\ׂ
bZ[W񂪓n܂B<br>
The log level is passed to <var>level</var> and the message character string that should be displayed is passed to <var>msg</var>.

</dl>

<hr>

<h3><a name="msgheader">msgheader W[ msgheader module</a></h3>

<p>msgheader W[DNS bZ[W̃wb_̉́AёgݗĂ
sW[łB<br>
msgheader module analyses and assembles the DNS message header.
<p>͂ꂽwb_́AɎ\̂ɓ܂BetB[h
DNS bZ[Wwb_̃tB[hɂ̂܂ܑΉĂ̂ŁA͏ȗ܂B<br>
Analyzed header information is placed in the following structure. Since each field corresponds to a field of DNS message header, the explanation is omitted here.
<blockquote>
<pre>
typedef struct mdn_msgheader {
	unsigned int id;
	int qr;
	int opcode;
	int flags;
	int rcode;
	unsigned int qdcount;
	unsigned int ancount;
	unsigned int nscount;
	unsigned int arcount;
} mdn_msgheader_t;
</pre>
</blockquote>

<p>ȉɃW[̒񋟂API֐܂B<br>
This module provides the following API functions.

<dl>

<dt><a name="mdn_msgheader_parse">mdn_msgheader_parse</a>
<dd>
<pre>
mdn_result_t
mdn_msgheader_parse(const char *msg, size_t msglen,
	mdn_msgheader_t *parsed)
</pre>
<p><var>msg</var>  <var>msglen</var> ŎDNSbZ[W̃wb_
͂A<var>parsed</var> \̂Ɋi[܂B<br>
Analyses the DNS message headers indicated by <var>msg</var> and <var>msglen</var> and stores the information in the structure indicated by <var>parsed</var>.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_invalid_message</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_invalid_message</tt>
<p>

<dt><a name="mdn_msgheader_unparse">mdn_msgheader_unparse</a>
<dd>
<pre>
mdn_result_t
mdn_msgheader_unparse(mdn_msgheader_t *parsed,
	char *msg, size_t msglen)
</pre>
<p>̊֐<em><a href="#mdn_msgheader_parse">mdn_msgheader_parse</a></em> 
t̏s܂B‚܂A<var>parsed</var> Ŏw肳ꂽ\̂̃f[^
DNSbZ[W̃wb_\A<var>msg</var>  <var>msglen</var> 
̈Ɋi[܂B<br>
This function performs reverse processing of <em><a href="#mdn_msgheader_parse">mdn_msgheader_parse</a></em>, in which the DNS message header is structured from the structure data specified by <var>parsed</var>, after which it is stored in the area specified by <var>msg</var> and <var>msglen</var>.

<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_buffer_overflow</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_buffer_overflow</tt>
<p>

<dt><a name="mdn_msgheader_getid">mdn_msgheader_getid</a>
<dd>
<pre>
unsigned int
mdn_msgheader_getid(const char *msg)
</pre>
<p><var>msg</var> Ŏw肳DNSbZ[W ID oĕԂ܂B
̊֐̓wb_Ŝ͂IDoƂɕ֗łB
̊֐́A<var>msg</var> ̎wf[^DNSbZ[W̃wb_ȏ゠
Ƃ肵Ă܂̂ŁAKĂяoŊmFĂĂяo悤
ĂB<br>
Extracts the ID from the DNS message specified by <var>msg</var> and returns it.
This function is only useful for extracting the ID without analyzing the entire header.
Since this function assumes the data indicated by <var>msg</var> is longer than the DNS message header length, always call the function after confirmation at the calling side.
<p>

<dt><a name="mdn_msgheader_setid">mdn_msgheader_setid</a>
<dd>
<pre>
void
mdn_msgheader_setid(char *msg, unsigned int id)
</pre>
<p><var>msg</var> Ŏw肳DNSbZ[W <var>id</var> Ŏw肳
ID ݒ肵܂B
̊֐ <var>msg</var> ̎wf[^DNSbZ[W̃wb_ȏ゠
Ƃ肵Ă܂̂ŁAKĂяoŊmFĂĂяo悤
ĂB<br>
Sets the ID specified by <var>id</var> in the DNS message specified by <var>msg</var>.
Since this function also assumes that the data indicated by <var>msg</var> is longer than the DNS message header length, always call the function after confirmation at the calling side.

</dl>

<hr>

<h3><a name="msgtrans">msgtrans W[ <br>
msgtrans module</a></h3>

<p>msgtrans W[DNS vLVT[oł DNS bZ[W̕ϊ
啔񋟂郂W[łB̃W[
<a href="#converter">converter W[</a>
<a href="#normalizer">normalizer W[</a>ȂǑ̑̃W[
̏ʃW[ƂĎĂ܂B<br>
The msgtrans module provides a large portion of DNS message conversion processing performed by the DNS proxy server. This module is implemented as a high-order module for many other modules including the <a href="#converter">converter module</a> and <a href="#normalizer">normalizer module</a>.

<p>DNSvLVT[oɂ郁bZ[Wῗ悻̂悤Ȃ̂łB<br>
Message conversion processing by the DNS proxy server is briefly explained below.
<p>܂NCAgDNST[oւ̃bZ[W̕ϊ̏ꍇ͎
悤ɂȂ܂B<br>
Conversion of a message from a client to the DNS server is as follows.
<ol>
<li>NCAgMNGXgbZ[W͂A
  NCAg ZLD уGR[fBO𔻒肵܂B<br>
Request message received from client is analyzed and ZLD and encoding at the client side are determined.
<li>茋ʂpāAhCZLDAGR[fBOUTF-8
  ϊ܂B<br>
Based on the determination result, ZLD are removed from domain names and encoding is converted to UTF-8.
<li>Ks܂B<br>
Normalization processing is performed.
<li>GR[fBO UTF-8DNST[oŗpGR[fBO
  ϊAZLDt܂B<br>
The encoding is converted from UTF-8 to the encoding method used by the DNS server side and ZLD are added.
<li>ȏ̏bZ[WɊ܂܂邷ׂẴhCɑ΂čsA
  ϊʂĂ DNS bZ[W`ɂ܂Ƃ߂ DNS T[oɑM܂B<br>
The above processing is performed on all domain names included in the message and the conversion results are collectively placed in the DNS message format and then sent to the DNS server.
</ol>

<p>DNST[oNCAgւ̃bZ[W̕ϊ̏ꍇ͎
悤ɂȂ܂B<br>
Conversion of messages from the DNS server to the client is as follows.
<ol>
<li>DNST[oMvCbZ[W͂A
  ܂܂Ă邷ׂẴhCɑ΂āAZLD̏AUTF-8GR[fBO
  ւ̕ϊs܂B<br>
The reply message received from the DNS server is analyzed and removal of ZLD and conversion to UTF-8 encoding are performed on all domain names included in the message.
<li>ɃNCAgGR[fBOɕϊAZLDt܂B<br>
Encoding is converted to the client side encoding and ZLD are added.
<li>ϊʂĂ DNS bZ[W`ɂ܂Ƃ߂ăNCAgɑM܂B<br>
The conversion results are collectively placed in the DNS message format and then sent to the client.
</ol>

<p>̂悤ɁADNSbZ[W̕ϊɍۂẮA
NCAgET[oZLDAGR[fBO
낢ȃp[^KvƂȂ܂BAPI֐ɂw肷ہA
ꂼʁẌŎw肷͔̂ώGȂ̂ŁÂ悤ȍ\̂
pĂ܂Ƃ߂ēn悤ɂĂ܂B<br>
As explained above, various parameters with respect to ZLD at the client/server side and encoding are necessary for DNS message conversion. When specifying those parameters for API functions, it is troublesome to specify them using different arguments for various functions. To avoid this, the following structure can be used to pass the parameters collectively.
<blockquote>
<pre>
typedef struct mdn_msgtrans_param {
	int use_local_rule;
	mdn_ZLDrule_t local_rule;
	mdn_converter_t local_converter;
	mdn_converter_t local_alt_converter;
	char *local_ZLD;
	mdn_converter_t target_converter;
	mdn_converter_t target_alt_converter;
	char *target_ZLD;
	mdn_normalizer_t normalizer;
} mdn_msgtrans_param_t;
</pre>
</blockquote>
<p><tt>use_local_rule</tt>́A͑̃bZ[WZLDуGR[fBO
@w肵܂B<br>
<tt>use_local_rule</tt> specifies the ZLD and encoding determination method fr the message at the input side.
<p>l^Ȃ΁A<tt>local_rule</tt>
w肳ZLDƃGR[fBȌWƃbZ[WɊ܂܂hC
}b`OsA}b`̂g܂B
̓NCAgDNST[oւ̃NGXgbZ[W̕ϊ̍ۂ
p܂B
̏ꍇA茋ʂ<tt>local_converter</tt><tt>local_ZLD</tt>
܂B<br>
When the value is true, matching processing is performed on the ZLD and encoding as specified by <tt>local_rule</tt> and the domain names included in the message, and the matches are used when converting the request message from the client to the DNS server; in this case, the judgement results are assigned to <tt>local_converter</tt> and <tt>local_ZLD</tt>.
<p>A<tt>local_rule</tt>UȂZLDуGR[fBO
<tt>local_converter</tt><tt>local_ZLD</tt>Ŏw肳̂̂܂
gp܂B
DNST[oNCAgւ̃NGXgbZ[W̕ϊ̍ۂ
p܂B
̏ꍇ<tt>local_rule</tt>̒l͎gp܂B<tt>use_local_rule</tt> ̒lɊւ炸A<tt>local_alt_converter</tt> ͓͑bZ[W̑փGR[fBOƂĎgp܂BփGR[fBOȂꍇɂ NULL w肵܂B<br>
On the other hand, if <tt>local_rule</tt> is false, the ZLD and encoding specified by <tt>local_converter</tt> and <tt>local_ZLD</tt> are used as is when converting the request message sent from DNS server to the client; in this case, the value of <tt>local_rule</tt> is not used.
Regardless of the value of <tt>use_local_rule</tt>, <tt>local_alt_converter</tt> defines the alternate encoding method used to encode the message at the input side.
When there is no alternate encoding, NULL is specified.
<p><tt>target_converter</tt> and <tt>target_ZLD</tt> are used to specify the output side encoding and ZLD.
<tt><tt>target_converter</tt><tt>target_ZLD</tt>ŏo͑
GR[fBOZLDw肵܂B
<tt>target_alt_converter</tt>́A<tt>target_converter</tt>ɂ
o͑̃GR[fBOւ̕ϊAϊ悤ƂhC
o͑̕WɂȂ܂܂Ă߂ɎsꍇɁA
<tt>target_converter</tt>̑Ɏgp܂B
Ȃ <tt>local_alt_converter</tt>  <tt>target_alt_converter</tt>
ɑΉGR[fBO͂
<a href="#ACE">ASCII ݊GR[fBO</a>łȂ΂Ȃ܂B<br>
target_alt_converter</tt> is alternately used with <tt>target_converter</tt> when the conversion by <tt>target_converter</tt> to the output side encoding fails because the domain name to be converted includes characters that do not exist in the output side character set. Note that the encoding corresponding to <tt>local_alt_converter</tt> and <tt>target_alt_converter</tt> must be <a href="#ACE">ASCII-compatible encoding</a>, respectively.
<p><tt>normalizer</tt>͐Kw肵܂B<br>
<tt>normalizer</tt> specifies normalization method.

<p>ȉɃW[̒񋟂API֐܂B<br>
This module provides the following API functions.

<dl>
<dt><a name="mdn_msgtrans_translate">mdn_msgtrans_translate</a>
<dd>
<pre>
mdn_result_t
mdn_msgtrans_translate(mdn_msgtrans_param_t *param,
	const char *msg, size_t msglen,
	char *outbuf, size_t outbufsize,
	size_t *outmsglenp)
</pre>
<p><var>msg</var>  <var>msglen</var> Ŏw肳DNSbZ[W
ϊp[^ <var>param</var> ɂĕϊAʂ
<var>outbuf</var>  <var>outbufsize</var> Ŏ̈Ɋi[܂B
<var>outmsglenp</var> ɂ͕ϊʂ̃bZ[Wi[܂B<br>
Converts the DNS messages specified by <var>msg</var> and <var>msglen</var> according to the conversion parameter <var>param</var> and stores the result in the area indicated by <var>outbuf</var> and <var>outbufsize</var>. The message length of the conversion result is stored in <var>outmsglenp</var>.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_invalid_message</tt>A
<tt>mdn_invalid_encoding</tt>A
<tt>mdn_buffer_overflow</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_invalid_message</tt>
<br><tt>mdn_invalid_encoding</tt>
<br><tt>mdn_buffer_overflow</tt>

</dl>

<hr>

<h3><a name="normalizer">normalizer W[ <br>
normalizer module</a></h3>

<p>normalizer W[͕̐KsW[łB
K̕ƂĂ͌ݎ̂̂pӂĂ܂B
܂ʂ̐VȐKljo^邽߂APIpӂĂ܂B<br>
normalizer module normalizes character string.
The following normalization methods are currently provided.
In addition, API used to additionally register new normalization method is provided.
<ul>
<li><tt>ascii-uppercase</tt><br>
    ASCII ̏啶ւ̕ϊ <br>
    Converts ASCII lowercase to uppercase
<li><tt>ascii-lowercase</tt><br>
    ASCII ̑啶珬ւ̕ϊ<br>
    Converts ASCII uppercase to lowercase
<li><tt>unicode-uppercase</tt><br>
    Unicode ̕K肵
    <a href="http://www.unicode.org/unicode/reports/tr21"><cite>Case Mappings</cite></a>
    ɋLqĂ鏬啶}bsOɏ]啶ւ̕ϊ <br>
Converts lowercase to uppercase in accordance with the lowercase/uppercase mapping described in <a href="http://www.unicode.org/unicode/reports/tr21"><cite>Case Mappings</cite></a> that prescribes character properties of Unicode.
<li><tt>unicode-lowercase</tt><br>
    LƓɂ啶珬ւ̕ϊ <br>
Converts uppercase to lowercase in accordance with the same above document.
<li><tt>unicode-form-c</tt><br>
Unicode ̐KK肵
    <a href="http://www.unicode.org/unicode/reports/tr15"><cite>Unicode Normalization Forms</cite></a>
    ɋLqĂ<em>Normaliztion form C</em> ɏ]K <br>
Normalizes characters in accordance with <em>Normaliztion form C</em> described in <a href="http://www.unicode.org/unicode/reports/tr15"><cite>Unicode Normalization Forms</cite></a> that prescribes normalization method of Unicode.
<li><tt>unicode-form-kc</tt><br>
ɋLqĂ <em>Unicode Normalization Form KC</em> 
    ]K <br>
    Normalizes characters in accordance with <em>Unicode Normalization Form KC</em> described in the above same document.
<li><tt>ja-kana-fullwidth</tt><br>
    {̔pȂSpJ^Jiւ̕ϊ <br>
Converts Japanese single-byte katakana to double-byte katakana.
<li><tt>ja-fullwidth</tt><br>
    <tt>ja-kana-fullwidth</tt> ƓB
    ͈ȑÕo[WƂ̌݊̂߂ɎcĂ̂ŁA
    ̃o[Wł͂ȂȂ”\܂B<tt>ja-kana-fullwidth</tt>
    gĂB<br>
Same as <tt>ja-kana-fullwidth</tt>.
    This is kept for compatibility with the previous version and may be eliminated in the future version. Use <tt>ja-kana-fullwidth</tt>.
<li><tt>ja-alnum-halfwidth</tt><br>
    {̑SppёSp}CiXL𔼊pɕϊ <br>
Converts Japanese double-byte alphanumeric characters and double-byte minus symbol to single-byte characters
<li><tt>ja-compose-voiced-sound</tt><br>
    {̑SpȂƂɑ_(J)_(K)
    _E_‚̂1ɕϊ <br>
Converts Japanese double-byte katakana and following voiced consonant mark (J) and circle attached to certain katakana (K) to one katakana character attached with voiced consonant mark or circle.
<li><tt>ja-minus-hack</tt><br>
    {̑Sp}CiXL(|)nCt(<tt>-</tt>)ւ̕ϊ <br>
Converts Japanese double-byte minus symbol (|) to hyphen(-). 
<li><tt>ja-delimiter-hack</tt><br>
    _(B)ёSpsIh(D)sIh(<tt>.</tt>)ւ̕ϊ <br>
Converts Japanese period (B) and double-byte period (D) to period (<tt>.</tt>).
</ul>
<p>Ō<tt>ja-delimiter-hack</tt>͋_ёSpsIh
hC̃Zp[^łsIhƌȂ悤ɂ̂ŁA
͖{hC̃[U͂̍ۂ̎ԂъԈႢy邽߂
pӂꂽ̂łAuEUɂĂ̓sIĥȂhC
hCł͂ȂL[[hƔFĂ܂Ȃǂ̖肪A
܂̓hC̐K͈̔͂EĂƂl̂ŁA
ł邾̐K̎gpׂ͔łB<br>
The last <tt>ja-delimiter-hack</tt> is to assume Japanese period and double-byte period as the period that is the separator of domain name. This is originally provided to reduce steps or mistakes when user enters multilingual domain names. However, depending on browser, there are problems that domain names without period are recognized as keyword not domain name and also this method is supposed to exceed the scope of normalization of domain names, therefore, use of this normalization method should be avoided as much as possible.

<p>K͕p邱Ƃ”\ŁȀꍇw肵ɓKp܂B<br>
More than one normalization methods can be used and they are applied in the order they were specified.
<p>normalizer W[́uKReLXgvƂTOp܂B
Ksɐ旧Ă܂KReLXg쐬Agp鐳KReLXgɓo^Ă܂Bۂ̐K̍ۂɂ͐Kł͂ȂA̐KReLXgw肵܂BKReLXǧ^<em>mdn_normalizer_t</em> ^łÂ悤 opaque ^ƂĒ`Ă܂B<br>
normalizer module uses the concept "normalization context". Prior to normalization, a normalization context is created and the normalization method to be used is registered in the context. For actual normalization procesesing, not the normalization method but this normalization context is specified. The type of normalization context is <em>mdn_normalizer_t</em> type and defined as the following opaque type.
<blockquote>
<pre>
typedef struct mdn_normalizer *mdn_normalizer_t;
</pre>
</blockquote>

<p>ȉɃW[̒񋟂API֐܂B<br>
This module provides the following API functions.

<dl>

<dt><a name="mdn_normalizer_initialize">mdn_normalizer_initialize</a>
<dd>
<pre>
mdn_result_t
mdn_normalizer_initialize(void)
</pre>
<p>W[̏s܂B{W[̑API֐ĂԑO
 KĂяoĂB<br>
Initializes module. Make sure to call this function before calling other API function of this module.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_nomemory</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_nomemory</tt>
<p>

<dt><a name="mdn_normalizer_create">mdn_normalizer_create</a>
<dd>
<pre>
mdn_result_t
mdn_normalizer_create(mdn_normalizer_t *ctxp)
</pre>
<p>Kp̋̃ReLXg쐬A<var>ctxp</var> ̎ẅɊi[܂B
ԂReLXg͋ŁAK͈‚܂܂Ă܂B
Kljɂ
<a href="#mdn_normalizer_add"><em>mdn_normalizer_add</em></a> p܂B<br>
Creates an empty content for normalization and stores it in the area specified by <var>ctxp</var>.
The returned content is empty and does not contain any normalization methods.
To add normalization method, <a href="#mdn_normalizer_add"><em>mdn_normalizer_add</em></a> is used.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_nomemory</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_nomemory</tt>
<p>

<dt><a name="mdn_normalizer_destroy">mdn_normalizer_destroy</a>
<dd>
<pre>
void
mdn_normalizer_destroy(mdn_normalizer_t ctx)
</pre>
<p><a href="#mdn_normalizer_create"><em>mdn_normalizer_create</em></a> 
쐬KReLXg폜AAP[gꂽ܂B<br>
Deletes the normalization context created by <a href="#mdn_normalizer_create"><em>mdn_normalizer_create</em></a> and releases the allocated memory.
<p>

<dt><a name="mdn_normalizer_add">mdn_normalizer_add</a>
<dd>
<pre>
mdn_result_t
mdn_normalizer_add(mdn_normalizer_t ctx, const char *scheme_name)
</pre>
<p><a href="#mdn_normalizer_create"><em>mdn_normalizer_create</em></a> 
쐬KReLXgɁA<var>scheme_name</var> Ŏw肳
Klj܂B‚̃ReLXgɕ̐K
lj邱Ƃł܂B<br>
Adds the normalization method specified by <var>scheme_name</var> in the normalization context created by <a href="#mdn_normalizer_create"><em>mdn_normalizer_create</em></a>. More than one normalization methods can be specified in one context.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_invalid_name</tt>A
<tt>mdn_nomemory</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_invalid_name</tt>
<br><tt>mdn_nomemory</tt>
<p>

<dt><a name="mdn_normalizer_normalize">mdn_normalizer_normalize</a>
<dd>
<pre>
mdn_result_t
mdn_normalizer_normalize(mdn_normalizer_t ctx,
	const char *from, char *to, size_t tolen)
</pre>
<p>UTF-8 ŃGR[hꂽ <var>from</var>  <var>ctx</var> 
w肳鐳KKpǍʂ <var>to</var>  <var>tolen</var> 
w肳̈ɏ݂܂B
<var>ctx</var> ɕ̐K܂܂ĂꍇA炪
<a href="#mdn_normalizer_add"><em>mdn_normalizer_add</em></a> ŒljԂ
Kp܂B<br>
Applies the normalization method specified by <var>ctx</var> to the character strings encoded by UTF-8 <var>from</var> and writes the result in the area specified by <var>to</var> and <var>tolen</var>.
When more than one normalization method is included in <var>ctx</var>, they are applied in the order they were added by <a href="#mdn_normalizer_add"><em>mdn_normalizer_add</em></a>.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_invalid_encoding</tt>A
<tt>mdn_nomemory</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_invalid_encoding</tt>
<br><tt>mdn_nomemory</tt>
<p>

<dt><a name="mdn_normalizer_register">mdn_normalizer_register</a>
<dd>
<pre>
mdn_result_t
mdn_normalizer_register(const char *scheme_name,
	mdn_normalizer_proc_t proc)
</pre>
<p>VK <var>scheme_name</var> ƂOœo^܂B
<var>proc</var> ͂̐K̏֐ւ̃|C^łB<br>
New normalization methods are registered in <var>scheme_name</var>.<var>proc</var> is a pointer to the processing function of that normalization method.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_nomemory</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_nomemory</tt>

</dl>

<hr>

<h3><a name="race">race W[ <br>
race module</a></h3>

<p>race W[́AhC̃GR[fBÖ‚Ƃ
ĂĂ
<a href="../../reference/draft/draft-ietf-idn-race-02.txt">RACE GR[fBO</a>
UTF-8Ƃ̊Ԃ̕ϊsW[łB̃W[
<a href="#converter">converter W[</a>̉ʃW[ƂĎĂA
AvP[ṼW[𒼐ڌĂяoƂ͂܂B
<a href="#converter">converter W[</a>ɑ΂ <tt>RACE</tt> GR[fBO
Ƃ̕ϊvƁÃW[ԐړIɌĂяo邱ƂɂȂ܂B<br>
The race module performs conversion between UTF-8 and the proposed <a href="../../reference/draft/draft-ietf-idn-race-02.txt">RACE</a> multilingual domain name  method. This module is implemented as a low-order module of <a href="#converter">converter module</a> and is not directly called by the application. When <a href="#converter">converter module</a> is requested for conversion with <tt>RACE</tt> encoding, this module is indirectly called.

<p>ȉɃW[̒񋟂API֐܂B<br>
This module provides the following API functions.

<dl>

<dt><a name="mdn__race_open">mdn__race_open</a>
<dd>
<pre>
mdn_result_t
mdn__race_open(mdn_converter_t ctx, mdn_converter_dir_t dir)
</pre>
<p>RACEGR[fBOƂ̕ϊI[v܂Bۂɂ͉܂B<br>
Opens conversion context with RACE encoding. Actually, this does not do anything.
<p> <tt>mdn_success</tt>Ԃ܂B<br>
Always returns <tt>mdn_success</tt>.
<p>

<dt><a name="mdn__race_close">mdn__race_close</a>
<dd>
<pre>
mdn_result_t
mdn__race_close(mdn_converter_t ctx, mdn_converter_dir_t dir)
</pre>
<p>RACEGR[fBOƂ̕ϊN[Y܂Bۂɂ͉܂B<br>
Closes conversion context with RACE encoding. Actually, this does not do anything.
<p> <tt>mdn_success</tt>Ԃ܂B<br>
Always returns <tt>mdn_success</tt>.
<p>

<dt><a name="mdn__race_convert">mdn__race_convert</a>
<dd>
<pre>
mdn_result_t
mdn__race_convert(mdn_converter_t ctx, mdn_converter_dir_t dir,
	const char *from, char *to, size_t tolen)
</pre>
<p>RACEGR[hꂽUTF-8GR[hꂽ̑ݕϊ
s܂B
͕ <var>from</var> ϊAʂ <var>to</var> 
<var>tolen</var> Ŏw肳̈ɏ݂܂B
<var>dir</var> <tt>mdn_converter_l2u</tt>Ȃ
RACEGR[fBOUTF-8GR[fBOցA<tt>mdn_converter_u2l</tt>
ȂUTF-8GR[fBORACEGR[fBOւ̕ϊƂȂ܂B<br>
Performs bidirectional conversion between RACE-encoded and UTF-8 encoded character strings. Converts the <var>from</var> input character string and writes the result in the area specified by <var>to</var> and <var>tolen</var>.
When <var>dir</var> is <tt>mdn_converter_l2u</tt>, RACE encoding is converted to UTF-8 encoding. When it is <tt>mdn_converter_u2l</tt>, UTF-8 encoding is converted to RACE encoding.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_buffer_overflow</tt>A
<tt>mdn_invalid_encoding</tt>A
<tt>mdn_nomemory</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_buffer_overflow</tt>
<br><tt>mdn_invalid_encoding</tt>
<br><tt>mdn_nomemory</tt>

</dl>

<hr>

<h3><a name="res">res W[ <br>
res module</a></h3>

<p>res W[̓NCAg (]oCuAvP[V)
őhC̏A‚܂hC̃GR[fBOϊ
Ksۂ̍x API 񋟂܂B
̃W[͂ƂŐ <a href="#resconf">resconf W[</a>
ƂƂɗp邱ƂOɐ݌vĂ܂B<br>
The res module provides high level APIs used when multilingual domain names are processed at the client side (by the resolver library or an application) i.e. when domain name encoding conversion or normalization is performed. This module is designed on the assumption that it will be used together with <a href="#resconf">resconf module</a>, which is explained below.

<p>̃W[̒񋟂 API gp΁A
<a href="#converter">converter W[</a>
<a href="#normalizer">normalizer W[</a>Ȃǂ̊֐𒼐
ĂяoKv͂܂B<br>
Using APIs provided by the module, it is not necessary to directly call <a href="#converter">converter module</a> or <a href="#normalizer">normalizer module</a> function.

<p>ȉɃW[̒񋟂API֐܂B<br>
This module provides the following API functions.

<dl>
<dt><a name="mdn_res_localtoucs">mdn_res_localtoucs</a>
<dd>
<pre>
mdn_result_t
mdn_res_localtoucs(mdn_resconf_t conf, const char *local_name,
	char *ucs_name, size_t ucs_name_len)
</pre>
<p>AvP[V̎gp郍[JGR[fBOŕ\ꂽ
hC <var>local_name</var>  UTF-8 ɕϊǍʂ
<var>ucs_name</var> Ɋi[܂B<var>ucs_name_len</var><var>ucs_name</var> Ɋmۂ̈̑傫w肵܂B<br>
Converts <var>local_name</var> domain name character strings expressed in the local encoding used by the application to UTF-8 and stores the result in <var>ucs_name</var>. <var>ucs_name_len</var> is used to specify the size of the area secured for <var>ucs_name</var> beforehand.

<p><var>conf</var>  <a href="#resconf">resconf W[</a> ̕Ԃ
NCAgݒReLXgłB <var>conf</var>  NULL ł
ϊ͍sꂸA<var>local_name</var> ̓ê܂ <var>ucs_name</var>
ɃRs[܂B<br>
<var>conf</var> is the client configuration context returned by <a href="#resconf">resconf module</a>. When <var>conf</var> is NULL, conversion is not performed and the contents of <var>local_name</var> is copied to <var>ucs_name</var> as is.

<p>hC <var>local_name</var> ] ASCII hCƂ
 (‚܂pуnCtƃsIh\)A
NCAgݒReLXg <var>conf</var> ɑփGR[fBO
ݒ肳ĂꍇA[JGR[fBOƂĂ̕ϊsO
փGR[fBO UTF-8 ̕ϊ݁Asꍇ
[JGR[fBO UTF-8 ւ̕ϊs܂BɂāA
<a href="#mdn_res_ucstolocal"><em>mdn_res_ucstolocal</em></a> 
^ꂽhC[JGR[fBOɕϊł
փGR[fBOɕϊꍇłA{֐ɗ^
 UTF-8 GR[fBÕhC܂B<br>
Conversion from local encoding to UTF-8 is performed when the <var>local_name</var> domain name is a valid conventional ASCII domain name (that is, it consists of alphanumeric characters, hyphens and periods), alternate encoding is set in the client configuraiton context <var>conf</var>, and conversion to UTF-8 from the alternate encoding is attempted and failed before conversion of the local encoding is performed. Because of this, even if <a href="#mdn_res_ucstolocal"><em>mdn_res_ucstolocal</em></a> could not convert the given domain name to the local encoding and converted to the alternate encoding, if it is given to this function, the correct UTF-8 encoded domain name can be obtained.

<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_buffer_overflow</tt>A
<tt>mdn_invalid_name</tt>A
<tt>mdn_failure</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_buffer_overflow</tt>
<br><tt>mdn_invalid_name</tt>
<br><tt>mdn_failure</tt>

<p>

<dt><a name="mdn_res_ucstolocal">mdn_res_ucstolocal</a>
<dd>
<pre>
mdn_result_t
mdn_res_ucstolocal(mdn_resconf_t conf, const char *ucs_name,
	char *local_name, size_t local_name_len)
</pre>
<p><a href="#mdn_res_localtoucs"><em>mdn_res_localtoucs</em></a> 
t̕ϊA‚܂ UTF-8 ŕ\ꂽhC <var>ucs_name</var>
AvP[V̎gp郍[JGR[fBOɕϊǍʂ
<var>local_name</var> Ɋi[܂B<var>local_name_len</var><var>local_name</var> Ɋmۂ̈̑傫w肵܂B<br>
Performs reverse conversion of <a href="#mdn_res_localtoucs"><em>mdn_res_localtoucs</em></a>, i.e., converts the <var>ucs_name</var> domain name character string expressed in UTF-8 to the local encoding used by the application and stores the result in <var>local_name</var>. <var>local_name_len</var> is used to specify the size of the area secured for <var>local_name</var> beforehand.

<p><var>conf</var>  <a href="#resconf">resconf W[</a> ̕Ԃ
NCAgݒReLXgłB <var>conf</var>  NULL ł
ϊ͍sꂸA<var>local_name</var> ̓ê܂ <var>ucs_name</var>
ɃRs[܂B<br>
<var>conf</var> is the client configuration context returned by <a href="#resconf">resconf module</a>. When <var>conf</var> is NULL, conversion is not performed and the contents of <var>local_name</var> is copied in <var>ucs_name</var> as is.

<p>hC <var>ucs_name</var> ̒Ƀ[JGR[fBO
WɂȂĕϊɎsꍇANCAgݒReLXg
<var>conf</var> ɑփGR[fBOݒ肳Ă΁A
[JGR[fBȎɑփGR[fBOւ̕ϊs܂B
ɂAƂ DNS T[o烍[JGR[fBOɊ܂܂Ȃ
܂ރhCԂꂽꍇɂG[ƂȂ炸ɕϊs܂B
ȂAփGR[fBOɕϊꂽ
<a href="#mdn_res_localtoucs"><em>mdn_res_localtoucs</em></a> ɂ
UTF-8 ɖ߂Ƃ”\łB<br>
When conversion fails because a character that is not in the character set of the local encoding is contained in the <var>ucs_name</var> domain name, if the alternate encoding is set in the client configuration context <var>conf</var>, conversion to the alternate encoding is performed instead of to the local encoding.
Because of this, even if the DNS server returns a domain name that includes a character that is not included in the local encoding, conversion is performed without error. Note that character strings converted to the alternate encoding can be returned to UTF-8 character strings by <a href="#mdn_res_localtoucs"><em>mdn_res_localtoucs</em></a>.

<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_buffer_overflow</tt>A
<tt>mdn_invalid_name</tt>A
<tt>mdn_failure</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_buffer_overflow</tt>
<br><tt>mdn_invalid_name</tt>
<br><tt>mdn_failure</tt>

<p>

<dt><a name="mdn_res_normalize">mdn_res_normalize</a>
<dd>
<pre>
mdn_result_t
mdn_res_normalize(mdn_resconf_t conf, const char *name,
                  char *normalized_name, size_t normalized_name_len)
</pre>
<p>NCAgݒReLXg <var>conf</var> ɂ
UTF-8 ŕ\ꂽhC <var>name</var> ɑ΂ĐKsA
̌ʂ <var>normalized_name</var> Ɋi[܂B
<var>normalized_name_len</var> ł炩 <var>normalized_name</var> 
mۂ̈̑傫w肵܂B<br>
Executes normalization on the <var>name</var> domain name expressed in UTF-8 according to the client configuration context <var>conf</var> and stores the result in <var>normalized_name</var>.
<var>normalized_name_len</var> is used to specify the size of the area secured for <var>normalized_name</var> beforehand.

<p> <var>conf</var>  NULL łΐK͍sꂸA
<var>name</var> ̓ê܂ <var>normalized_name</var> ɃRs[܂B<br>
When <var>conf</var> is NULL, normalization is not performed and the contents of <var>name</var> is copied in <var>normalized_name</var> as is.

<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_buffer_overflow</tt>A
<tt>mdn_invalid_encoding</tt>A
<tt>mdn_nomemory</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_buffer_overflow</tt>
<br><tt>mdn_invalid_encoding</tt>
<br><tt>mdn_nomemory</tt>

<p>

<dt><a name="mdn_res_ucstodns">mdn_res_ucstodns</a>
<dd>
<pre>
mdn_result_t
mdn_res_ucstodns(mdn_resconf_t conf, const char *ucs_name, char *dns_name,
	size_t dns_name_len)
</pre>
<p>NCAgݒReLXg <var>conf</var> ɂ
UTF-8 ŕ\ꂽhC <var>ucs_name</var>  DNS vgR
pGR[fBOɕϊǍʂ <var>dns_name</var> 
i[܂B
<var>dns_name_len</var> ł炩 <var>dns_name_len</var> 
mۂ̈̑傫w肵܂B<br>
Converts the <var>ucs_name</var> domain name expressed in UTF-8 to the encoding used in the DNS protocol per the <var>conf</var> client configuration context and stores the result in <var>dns_name</var>. <var>dns_name_len</var> is used to specify the size of the area secured for <var>dns_name_len</var> beforehand.

<p> <var>conf</var>  NULL łΕϊ͍sꂸA
<var>ucs_name</var> ̓ê܂ <var>dns_name</var> ɃRs[܂B<br>
When <var>conf</var> is NULL, conversion is not performed and the contents of <var>ucs_name</var> are copied to <var>dns_name</var> as is.

<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_buffer_overflow</tt>A
<tt>mdn_invalid_encoding</tt>A
<tt>mdn_invalid_name</tt>A
<tt>mdn_failure</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_buffer_overflow</tt>
<br><tt>mdn_invalid_encoding</tt>
<br><tt>mdn_invalid_name</tt>
<br><tt>mdn_failure</tt>

<p>

<dt><a name="mdn_res_dnstoucs">mdn_res_dnstoucs</a>
<dd>
<pre>
mdn_result_t
mdn_res_dnstoucs(mdn_resconf_t conf, const char *dns_name, char *ucs_name,
	size_t ucs_name_len)
</pre>
<p><a href="#mdn_res_ucstodns"><em>mdn_res_ucstodns</em></a> ̋tϊA
‚܂NCAgݒReLXg <var>conf</var> ɂ
DNS vgR̃GR[fBOŕ\ꂽhC <var>dns_name</var>
 UTF-8 ɕϊǍʂ <var>ucs_name</var> Ɋi[܂B
<var>ucs_name_len</var> ł炩 <var>ucs_name_len</var> 
mۂ̈̑傫w肵܂B<br>
Performs reverse conversion of <a href="#mdn_res_ucstodns"><em>mdn_res_ucstodns</em></a>, i.e., converts the <var>dns_name</var> domain name expressed in the encoding used in the DNS protocol to UTF-8 per the <var>conf</var> client configuration context and stores the result in <var>ucs_name</var>. <var>ucs_name_len</var> is used to specify the size of the area secured for <var>ucs_name_len</var> beforehand.

<p> <var>conf</var>  NULL łΕϊ͍sꂸA
<var>dns_name</var> ̓ê܂ <var>ucs_name</var> ɃRs[܂B<br>
When <var>conf</var> is NULL, conversion is not peformed and the contents of <var>dns_name</var> are copied to <var>ucs_name</var> as is.

<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_buffer_overflow</tt>A
<tt>mdn_invalid_encoding</tt>A
<tt>mdn_invalid_name</tt>A
<tt>mdn_failure</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_buffer_overflow</tt>
<br><tt>mdn_invalid_encoding</tt>
<br><tt>mdn_invalid_name</tt>
<br><tt>mdn_failure</tt>

</dl>

<hr>

<h3><a name="resconf">resconf W[ <br>
resconf module</a></h3>

<p>resconf W[̓NCAg (]oCuAvP[V)
őhC̏sۂɎQƂ
<a href="clientconfig.html">NCAgݒt@C</a>ǂݍ݁A
t@CɋLqꂽݒɂs܂B܂
ݒo@\񋟂܂B<br>
The resconf module loads the <a href="clientconfig.html"> client configuration file</a> referenced when a multilingual domain name is processed at the client side (by a resolver library or application) and executes initialization in accordance with the settings described in the file. It also provides a function to extract the setting information.

<p>resconf W[́uNCAgݒReLXgvƂTOp܂B
NCAgݒt@CɋLqꂽݒ͂̃NCAgݒReLXg
i[ÃReLXgɂ API ֐ĂяoƂɂ
ݒ肳ꂽloƂł܂B
NCAgݒReLXǧ^ <em>mdn_resconf_t</em> ^łA
̂悤 opaque ^ƂĒ`Ă܂B<br>
The resconf module uses the "client configuration context" concept.
Settings described in the client configuration file are stored in this client configuration context, which is used as an argument to call API functions to extract the set values. The client configuration context is defined by <em>mdn_resconf_t</em> and is of the following opaque type.
<blockquote>
<pre>
typedef struct mdn_resconf *mdn_resconf_t;
</pre>
</blockquote>

</pre>
</blockquote>
<p>̃W[͒P̂łgpł܂A
<a href="#res">res W[</a>Ƒgݍ킹邱ƂɂāA
NCAgł̑hC̏ȒPɍsƂł悤
݌vĂ܂B<br>
This module can be used as a single module but it is designed so that by combining it with <a href="#res">res module</a> multilingual domain names can easily be processed at the client side.

<p>ȉɃW[̒񋟂API֐܂B<br>
This module provides the following API functions.

<dl>

<dt><a name="mdn_resconf_initialize">mdn_resconf_initialize</a>
<dd>
<pre>
mdn_result_t
mdn_resconf_initialize(void)
</pre>
<p>hC̏sۂɕKvȏs܂B
{W[̑API֐ĂԑOɕKĂяoĂB
{W[gp鑼̃W[ׂ̏čŝŁAȊȌ
֐ĂяoKv͂܂B<br>
Executes initialization required when processing multilingual domain names. Always call this function before calling other API functions of this module. Since this function initializes all other modules used by this module, it is not necessary to call another initialization function.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_nomemory</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_nomemory</tt>
<p>

<dt><a name="mdn_resconf_create">mdn_resconf_create</a>
<dd>
<pre>
mdn_result_t
mdn_resconf_create(mdn_resconf_t *ctxp)
</pre>
<p>NCAgݒReLXg쐬AA<var>ctxp</var> ̎w
̈Ɋi[܂B
Ԃł́A܂NCAgݒt@C̓e͓ǂݍ܂Ă܂B
ǂݍނ߂ɂ <a href="#mdn_resconf_loadfile">
<em>mdn_resconf_loadfile</em></a> sKv܂B<br>
Creates and initializes client configuration context and stores it in the area indicated by <var>ctxp</var>. In the initial status, the contents of the client configuration file are not loaded. To do so, <a href="#mdn_resconf_loadfile"> <em>mdn_resconf_loadfile</em></a> must be executed.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_nomemory</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_nomemory</tt>
<p>

<dt><a name="mdn_resconf_destroy">mdn_resconf_destroy</a>
<dd>
<pre>
void
mdn_resconf_destroy(mdn_resconf_t ctx)
</pre>
<p><a href="mdn_resconf_create"><em>mdn_resconf_create</em></a> 
쐬ꂽNCAgݒReLXg폜Amۂ܂B<br>Deletes the client configuration context created by <a href="mdn_resconf_create"><em>mdn_resconf_create</em></a> and releases the allocated memory.
<p>

<dt><a name="mdn_resconf_loadfile">mdn_resconf_loadfile</a>
<dd>
<pre>
mdn_result_t
mdn_resconf_loadfile(mdn_resconf_t ctx, const char *file)
</pre>
<p><var>file</var> Ŏw肳
<a href="clientconfig.html">NCAgݒt@C</a>̓eǂݍ݁A
ݒeNCAgݒReLXg <var>ctx</var> Ɋi[܂B
<var>file</var>  NULL ̏ꍇɂ̓ftHg̃NCAgݒt@C
eǂݍ݂܂B<br>
Loads the contents of the <a href="clientconfig.html">client configuration file</a> specified by <var>file</var> and stores the setting contents in the <var>ctx</var> client configuration context.
When <var>file</var> is NULL, the contents of the default client configuration file are loaded.
<p>łɐݒt@Cǂݍ܂ĂReLXgɑ΂āA
ʂ̐ݒt@C̓eǂݍނƂł܂B̏ꍇɂ́A
NCAgݒReLXgɊi[ĂO̐ݒt@C̓e
ׂďAVɓǂݍ񂾐ݒt@C̓eŒu܂B<br>
If the configuration file has already been loaded and another configuration file is loaded, the previous configuration file contents stored in the client configuration context are erased and replaced with the newly loaded configuration file contents.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_nofile</tt>A
<tt>mdn_invalid_syntax</tt>A
<tt>mdn_invalid_name</tt>A
<tt>mdn_nomemory</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_nofile</tt>
<br><tt>mdn_invalid_syntax</tt>
<br><tt>mdn_invalid_name</tt>
<br><tt>mdn_nomemory</tt>
<p>

<dt><a name="mdn_resconf_defaultfile">mdn_resconf_defaultfile</a>
<dd>
<pre>
char *
mdn_resconf_defaultfile(void)
</pre>
<p>ftHg̃NCAgݒt@C̃pXԂ܂B
 mDNkit ̃RpC̐ݒɂČ܂܂AɎw肵Ȃ <br>
Returns the path to the default client configuration file. This is determined by the settings set when mDNkit is compiled. The default path is as follows:
<blockquote>
<pre>
/usr/local/etc/mdnres.conf
</pre>
</blockquote>
łB
<p>

<dt><a name="mdn_resconf_localconverter">mdn_resconf_localconverter</a>
<dd>
<pre>
mdn_converter_t
mdn_resconf_localconverter(mdn_resconf_t ctx)
</pre>
<p>NCAgݒReLXg <var>ctx</var> ̏ɁA
[JGR[fBO UTF-8 Ƃ̊Ԃ̕R[hϊs߂
R[hϊReLXgԂ܂B[JGR[fBOʂłȂ
ꍇɂ NULL Ԃ܂B<br>
Based on the <var>ctx</var> client configuration context information, returns the code conversion context to perform character code conversion between the local encoding and UTF-8. NULL is returned if the local encoding cannot be determined.
<p>R[hϊReLXgɂ‚Ă
<a href="#converter">converter W[</a> ̍B<br>
For details of code conversion context, refer to the <a href="#converter">converter module</a> section.
<p>

<dt><a name="mdn_resconf_alternateconverter">mdn_resconf_alternateconverter</a>
<dd>
<pre>
mdn_converter_t
mdn_resconf_alternateconverter(mdn_resconf_t ctx)
</pre>
<p>NCAgݒReLXg <var>ctx</var> ̏ɁA
փGR[fBO UTF-8 Ƃ̊Ԃ
R[hϊs߂̃R[hϊReLXgԂ܂B
փGR[fBOƂ̓hC[JGR[fBOɕϊ邱Ƃ
łȂꍇɁA[JGR[fBȎɗp
GR[fBÔƂłB
NCAgݒt@C܂ǂݍ܂ĂȂAݒt@C
GR[fBO̎w肪Ȃꍇɂ NULL Ԃ܂B<br>
Based on the <var>ctx</var> client configuration context information, returns the code conversion context to perform character code conversion between the alternate encoding and UTF-8. The alternate encoding is used instead of the local encoding when a domain name could not be converted to the local encoding. NULL is returned if the client configuration file has not been loaded or the encoding method is not specified in the configuration file.
<p>R[hϊReLXgɂ‚Ă
<a href="#converter">converter W[</a> ̍B<br>
For code conversion context, refer to <a href="#converter">converter module</a> section.
<p>

<dt><a name="mdn_resconf_serverconverter">mdn_resconf_serverconverter</a>
<dd>
<pre>
mdn_converter_t
mdn_resconf_serverconverter(mdn_resconf_t ctx)
</pre>
<p>NCAgݒReLXg <var>ctx</var> ̏ɁA
DNS vgRŗpGR[fBO UTF-8 Ƃ̊Ԃ
R[hϊs߂̃R[hϊReLXgԂ܂B
NCAgݒt@C܂ǂݍ܂ĂȂAݒt@C
GR[fBO̎w肪Ȃꍇɂ NULL Ԃ܂B<br>
Based on the information of client configuration context ctx, returns the code conversion context to perform character code conversion between the encoding used on DNS protocol and UTF-8. NULL is returned if the client configuration file has not been loaded or the encoding method is not specified in the configuration file.

<p>R[hϊReLXgɂ‚Ă
<a href="#converter">converter W[</a> ̍B<br>
For code conversion context, refer to <a href="#converter">converter module</a>  section. 
<p>

<dt><a name="mdn_resconf_ZLD">mdn_resconf_ZLD</a>
<dd>
<pre>
const char *
mdn_resconf_ZLD(mdn_resconf_t ctx)
</pre>
<p>NCAgݒReLXg <var>ctx</var> ̏ɁA
hCƏ]̃hCƂʂ邽߂Ɉꕔ
GR[fBOƂƂɗp ZLD ̕Ԃ܂B
ZLD gpȂݒ̏ꍇɂ NULL Ԃ܂B<br>
Based on the information in the <var>ctx</var> client configuration context, returns the ZLD character string used together with some encoding methods to differentiate between multilingual domain names and conventional domain names. NULL is returned when ZLD is not used.
<p>mDNkit ̓ftHg̐ݒł ZLD T|[gÅ֐͏
NULL Ԃ܂BmDNkit  ZLD T|[g悤ɐݒ肷@
‚Ă mDNkit ̃CXg[KCh
<a href="../guide/install.html#configure"><tt>configure</tt> s</a>
̍B<br>
By default, mDNkit does not support ZLD and this function always returns NULL. For details of how to set mKNkit to support ZLD, refer to <a href="../guide/install.html#configure"><tt>configure</tt> execute</a> in the mDNkit Installation Guide.
<p>

<dt><a name="mdn_resconf_normalizer">mdn_resconf_normalizer</a>
<dd>
<pre>
mdn_normalizer_t
mdn_resconf_normalizer(mdn_resconf_t ctx)
</pre>
<p>NCAgݒReLXg <var>ctx</var> ̏ɁA
hC𐳋K邽߂̐KReLXgԂ܂B
NCAgݒt@C܂ǂݍ܂ĂȂAݒt@C
K̎w肪Ȃꍇɂ NULL Ԃ܂B<br>
Based on the information of client configuration context ctx, returns the normalization context used to normalize domain names.
NULL is returned if the client configuration file has not been loaded or the normalization method is not specified in the configuration file.
<p>KReLXgɂ‚Ă
<a href="#normalizer">normalizer W[</a> ̍B<br>
For details of normalization context, refer to the <a href="#normalizer">normalizer module</a> section.

</dl>

<hr>

<h3><a name="result">result W[ result module</a></h3>

<p>result W[̓Cůe֐Ԃ
<a href="#mdn_result_t"><tt>mdn_result_t</tt>^̒l</a>W[ŁA
l炻̃R[hɑΉ郁bZ[Wւ̕ϊ񋟂܂B<br>
The result module handles the <a href="#mdn_result_t"><tt>mdn_result_t</tt> type value</a> returned by each function in the library and converts the value to the corresponding message code.

<p>ȉɃW[̒񋟂API֐܂B<br>
This module provides the following API functions.

<dl>

<dt>
<dd>
<pre>
char *
mdn_result_tostring(mdn_result_t result)
</pre>
<p><tt>mdn_result_t</tt>^̒l <var>result</var> ɑΉ
bZ[WԂ܂B<br>
Returns the message character string corresponding to the value <var>result</var> of <tt>mdn_result_t</tt> type.
<p>`̃R[hɑ΂Ă <tt>unknown result code</tt> Ƃ
Ԃ܂B<br>
An <tt>unknown result code</tt> character string is returned for undefined code.

</dl>

<hr>

<h3><a name="selectiveencode">selectiveencode W[ selectiveencode module</a></h3>

<p>selectiveencode W[̓][}X^t@C̃eLXg̒
ASCII܂ރhCToW[łB
eLXĝǂ̕hCȂ̂𔻒肷邱Ƃ͈ʓIɂ
s”\Ȃ̂ŁAۂɂ͎̂悤ȑ傫ȉuƂɂ
ߎIɎĂ܂B<br>
The selectiveencode module finds domain names that include non-ASCII characters in text such as zone master files. Generally speaking it is of course impossible to determine which part of the text is the domain name; in actuality, however, the following rough assumptions are used to approximately implement it.
<ul>
<li>ASCII̓hC̒ɂ̂݌ <br>
Non-ASCII characters appear only in domain names.
</ul>
<p>̓Iɂ͎̂悤ȃASYpăhC̗̈挟os܂B<br>
Specifically, the following algorithm is used to detect the domain name area.
<ol>
<li>eLXg𑖍āAASCIITB<br>
Scans the text and finds non-ASCII characters.
<li>‚ASCIȊO̕𒲂ׁA
    ̕܂݁A‘̔ASCII邢͏](ꉻĂȂ)
    hCƂĎgp”\ȕȂ͈͂߂B<br>
Check characters before and after found non-ASCII characters to determine a range consisting of only the found character and also other non-ASCII characters or characters that can be used for conventional (not internationalized) domain names. 
<li>߂͈͂hCƂĕԂB<br>
Returns the found range as the domain name.
</ol>

<p>ȉɃW[̒񋟂API֐܂B<br>
This module provides the following API functions.

<dl>

<dt><a name="mdn_selectiveencode_findregion">mdn_selectiveencode_findregion</a>
<dd>
<pre>
mdn_result_t
mdn_selectiveencode_findregion(const char *s,
	char **startp, char **endp)
</pre>
<p>UTF-8ŃGR[hꂽ <var>s</var> 𑖍āAŏɏo
ASCII܂ރhC̗̈߁A̐擪w|C^
<var>startp</var> ɁÄ̒̕w|C^ <var>endp</var> 
ꂼi[܂B<br>
Scans <var>s</var> UTF-8 encoded character strings and finds the area in the domain that includes the first appearance of a non-ASCII character, then stores a pointer indicating the beginning of the area at <var>startp</var> and a pointer indicating the end of the area in <var>endp</var>.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_notfound</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_notfound</tt>

</dl>

<hr>

<h3><a name="strhash">strhash W[ <br>
strhash module</a></h3>

<p>strhash W[͕L[ƂnbV\郂W[łB
nbV\
<a href="converter">converter W[</a>
<a href="normalizer">normalizer W[</a>ȂǃCȗ̃W[
gp܂B
ɈʓIȃnbV\̎łAMׂ_͂܂c
‚܂Bo^͂ł܂폜̋@\܂B{Cuł
KvȂłB<br>
The strhash module implements a hash table that uses a character string as a key. The hash table is used by other modules in the library such as the <a href="converter">converter module</a> and <a href="normalizer">normalizer module</a>. This is a very general hash table implementation in which registration can be performed but there is no deletion function because it is not needed with this library.

<p>nbV\̃TCY͗vf̑ɏ]đ傫Ȃ܂B<br>
The size of the hash table increases as the total numer of elements increases.

<p>nbV\͎Ɏ <em>mdn_strhash_t</em> ^ opaque f[^Ƃ
\܂B<br>
As shown below, the hash table is expressed in opaque data of <em>mdn_strhash_t</em> type.
<blockquote>
<pre>
typedef struct mdn_strhash *mdn_strhash_t;
</pre>
</blockquote>

<p>ȉɃW[̒񋟂API֐܂B<br>
This module provides the following API functions.

<dl>

<dt><a name="mdn_strhash_create">mdn_strhash_create</a>
<dd>
<pre>
mdn_result_t
mdn_strhash_create(mdn_strhash_t *hashp)
</pre>
<p>̃nbV\쐬Ãnh <var>hashp</var> ̎ẅ
i[܂B<br>
Creates an empty hash table and stores the handle to the area indicated by <var>hashp</var>. 
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_nomemory</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_nomemory</tt>
<p>

<dt><a name="mdn_strhash_destroy">mdn_strhash_destroy</a>
<dd>
<pre>
void
mdn_strhash_destroy(mdn_strhash_t hash)
</pre>
<p><a href="#mdn_strhash_create"><em>mdn_strhash_create</em></a> ō쐬
nbV\폜Amۂ܂B<br>
Deletes the hash table created by <a href="#mdn_strhash_create"><em>mdn_strhash_create</em></a> and releases the allocated memory.
<p>

<dt><a name="mdn_strhash_put">mdn_strhash_put</a>
<dd>
<pre>
mdn_result_t
mdn_strhash_put(mdn_strhash_t hash, const char *key,
	void *value)
</pre>
<p><a href="#mdn_strhash_create"><em>mdn_strhash_create</em></a> ō쐬
nbV\ <var>hash</var> ɃL[ <var>key</var>Al <var>value</var> ̑g
o^܂B
 <var>key</var> ̓Rs[܂̂ŁÅ֐̌Ăяo
<var>key</var> ̎wĂA̓eĂ
e͂܂Bɑ΂ <var>value</var> ̓e̓Rs[Ȃ̂
ӂĂ (悭lĂ݂΃Rs[ȂƂ͎ł)B<br>
Used to register a <var>key</var> and <var>value</var> set in the hash table created by <a href="#mdn_strhash_create"><em>mdn_strhash_create</em></a>.
Since character strings are copied, there is no influence even if the memory indicated by <var>key</var> is released or the contents of the character strings are changed after this function is called. Contrarily, the contents of <var>value</var> are not copied, so use care when working with this item. (If you think carefully about it, it will become obvious that this value is not copied.)
<p>L[gpĕo^ꍇAŌɓo^ꂽ̂
LłB<br>
When the same key is used for registration more than once, only the most recently registered key is effective.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_nomemory</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_nomemory</tt>
<p>

<dt><a name="mdn_strhash_get">mdn_strhash_get</a>
<dd>
<pre>
mdn_result_t
mdn_strhash_get(mdn_strhash_t hash,
	const char *key, void **valuep)
</pre>
<p>nbV\ <var>hash</var> L[ <var>key</var> —vfA
Ήvf΂̒l <var>valuep</var> Ɋi[܂B<br>
Searches for elements that have <var>key</var> in the <var>hash</var> table; if a corresponding element is found, the value is stored in <var>valuep</var>.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_noentry</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_noentry</tt>
<p>

<dt><a name="mdn_strhash_exists">mdn_strhash_exists</a>
<dd>
<pre>
int
mdn_strhash_exists(mdn_strhash_t hash, const char *key)
</pre>
<p>nbV\ <var>hash</var> ɃL[ <var>key</var> —vf
10 Ԃ܂B<br>
Returns 1 if there is an element that has the <var>key</var> in the <var>hash</var> table, and returns 0 if no element is found.

</dl>

<hr>

<h3><a name="translator">translator W[ <br>
translator module</a></h3>

<p>translator W[́A^ꂽp[^ɏ]ăhC
ϊ郂W[łBp[^ƂĂ͎ɂf[^^܂B<br>
The translator module converts domain names in accordance with the given parameters. Values can provided for the following parameters.
<ul>
<li>͂ƂēnhC̃GR[fBO ([JGR[fBO)<br>
Encoding (local encoding) of domain name passed as input
<li>͂ƂēnhC̑փGR[fBO
    ([JփGR[fBO)<br>
Alternate encoding of domain name passed as input (local alternate encoding)
<li>͂ƂēnhCZLD ([J ZLD)<br>
ZLD (local ZLD) of domain name passed as input
<li>K
Normalization method
<li>hC̕ϊ̃GR[fBO (^[QbgGR[fBO)<br>
Encoding after conversion of domain name (target encoding)
<li>^[QbgGR[fBOւ̕ϊsɗpGR[fBO
    (^[QbgփGR[fBO)<br>
Encoding used when conversion to target encoding failed (target alternate encoding)
<li>hC̕ϊZLD (^[QbgZLD)<br>
ZLD after conversion of domain name (target ZLD)
</ul>

<p>hC̕ϊ̎葱͂╡GłB͎̗Rɂ܂B<br>
The domain name conversion procedure is complicated, for the following reasons:
<ul>
<li>hCƂďɑhCn킯ł͂ȂA
    ]ASCIIhCn”\A
    ̂ǂł邩ɂďςKv邱 <br>
Multilingual domain names are not always passed as the domain name, and it is possible that conventional ASCII domain names may be passed and processing thus must be changed accordingly.
<li>܂2‚𔻕ʂ鏈ASCII݊GR[fBȌꍇ
    ȒPł͂ȂAZLDQƂKv邱 <br>
With regard to ASCII-compatible encoding, differentiating between multilingual domain names and conventional ASCII domain names is not simple and ZLD, etc. need to be referenced.
<li>Ƀ[JփGR[fBOŃGR[hꂽhC
    n”\邱 <br>
Domain names may be passed that are encoded using local alternate encoding.
<li>Ƀ^[QbgGR[fBOւ̕ϊsɂ
    փGR[fBOɎgpKv邱 <br>
If conversion to the target encoding fails, alternate encoding must be used instead.
</ul>

<p>̓Iɂ́Â悤ȃASYgpĕϊs܂B<br>
Specifically, the following algorithm is used for conversion.
<ol>
<li>[JZLD`Ă (łȂ) ǂ𒲂ׂB<br>
Checks if the local ZLD is defined (empty or not).
<li>`Ă΁AnꂽhCɃ}b`邩ǂׂB<br>
If it is defined, checks whether or not the passed domain name matches.
<li>}b`ΑhCƔfAhCZLDA
    6̃R[hϊւƈڂB<br>
    }b`Ȃ΁A]ASCIIhCƂĂ̂܂
    Rs[AIB<br>
If it matches, the domain name is determined to be a multilingual doman name and ZLD is removed from the domain, then processing proceeds to code conversion processing (Step 6).
<li>[JZLD`ĂȂ΁A[JGR[fBO
    ASCII݊GR[fBOł邩ǂA܂nꂽhC
    ]ASCIIhCƂĐ̂ł邩ǂ𒲂ׂB<br>
When the local ZLD is not defined, checks whether or not the local encoding is ASCII-conpatible and also that the passed domain name is a valid conventional ASCII domain name.
<li>ASCII݊GR[fBOł邩A邢͓nꂽhC
    ]ASCIIhCƂĐȂĂ
    hCłƂ6̃R[hϊւƈڂB<br>
    ȊȌꍇɂ͏]ASCIIhCƂĂ̂܂ 
    Rs[AIB<br>
When ASCII compatible encoding is used or the passed domain name includes an invalid character in a conventional ASCII domain name, the passed domain name is assumed to be a multilingual domain name and the procedure proceeds to code conversion processing (Step 6).<br>
For situations other than the above, the passed domain name is assumed to be a conventional ASCII-domain name and is copied as is, then processing ends.
<li>[JփGR[fBO`Ă΁A܂
    [JփGR[fBO UTF-8 ւƃR[hϊsB
    8̐KւƈڂB<br>
When the local alternate encoding is defined, the code is first converted from the local alternate encoding to UTF-8. If this is successful, processing proceeds to normalization processing (Step 8).
<li>[JGR[fBOUTF-8ւƃR[hϊsB<br>
Executes code conversion from local encoding to UTF-8.
<li>KsB<br>
Executes normalization processing.
<li>UTF-8^[QbgGR[fBOւƃR[hϊsB<br>
Executes code conversion from UTF-8 to the target encoding.
<li>hCɃ^[QbgGR[fBO̕WɂȂ
    ϊɎsꍇɂ́A UTF-8 փGR[fBOւ
    R[hϊsB<br>
If the conversion fails because there is a character in the domain name that is not included in the target character set, code conversion from UTF-8 to the alternate encoding is executed instead.
<li>^[QbgZLD`Ă΃hCɒljB<br>
When the target ZLD is defined, it is added to the domain name.
</ol>

<p>ȏ̏t[`[gŕ\̂̐}łB<br>
The following flow chart explains the above procedure.

<blockquote>
<img src="img/translator.jpg" alt="name translation flowchart">
</blockquote>

<p>{W[̓GR[fBOϊ
<a href="#converter">converter W[</a>A܂K
<a href="#normalizer">normalizer W[</a>ꂼgp܂B<br>
This module uses the <a href="#converter">converter module </a> for encoding and the <a href="#normalizer">normalizer module </a> for normalization.

<p>ȉɃW[̒񋟂API֐܂B<br>
This module provides the following API functions.

<dl>

<dt><a name="mdn_translator_translate">mdn_translator_translate</a>
<dd>
<pre>
mdn_result_t
mdn_translator_translate(mdn_converter_t local_converter,
	mdn_converter_t local_alternate_converter,
	const char *local_ZLD,
	mdn_normalizer_t normalizer,
	mdn_converter_t target_converter,
	mdn_converter_t target_alternate_converter,
	const char *target_ZLD,
	const char *from, char *to, size_t tolen)
</pre>
<p>^ꂽp[^ɂăhC <var>from</var> ϊA
ʂ <var>to</var>  <var>tolen</var> Ŏw肳̈Ɋi[܂B<br>
Converts the domain name produced by <var>from</var> per the specified parameters and stores the result in the area specified by <var>to</var> and <var>tolen</var>.
<p>[JGR[fBOA[JփGR[fBOA
^[QbgGR[fBOу^[QbgփGR[fBO
GR[fBÔ̖ł͂ȂA
Ή<a href="#converter">converter W[</a>
R[hϊReLXg <var>local_converter</var>A
<var>alternate_converter</var>  <var>target_converter</var> 
w肵܂B<br>
Local encoding, local alternate encoding, target encoding and target alternate encoding are not the actual names of types of encoding and are specified by the corresponding code conversion context, which is defined by the following <a href="#converter">converter module</a> variables: <var>local_converter</var>,<var>alternate_converter</var> and <var>target_converter</var>.
<p>^[QbgփGR[fBO <var>target_alternate_converter</var> ́A
<var>target_converter</var> ɂ^[QbgGR[fBOւ̕ϊA
hC^[QbgGR[fBO̕WɂȂ܂ł邽߂
sɁA^[QbgGR[fBȎɎgp܂B<br>
The <var>target_alternate_converter</var> variable is used instead of the target encoding if conversion to the target encoding by <var>target_converter</var> fails because the domain name contains a character that is not included in the target character set.
<p>K<a href="#normalizer">normalizer W[</a>̐KReLXg
<var>normalizer</var> Ŏw肵܂B<br>
Normalization is specified by normalization context defined by the <var>normalizer</var> variable of the <a href="#normalizer">normalizer module</a>.
<p>[JZLDу^[QbgZLD
<a href="#mdn_translator_canonicalZLD"><em>mdn_translator_canonicalZLD</em></a>
ŕW`ɕϊ̂łȂ΂Ȃ܂B<br>
The local ZLD and target ZLD must have been converted to the standard format by <a href="#mdn_translator_canonicalZLD"><em>mdn_translator_canonicalZLD</em></a>.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_buffer_overflow</tt>A
<tt>mdn_invalid_encoding</tt>A
<tt>mdn_nomemory</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_buffer_overflow</tt>
<br><tt>mdn_invalid_encoding</tt>
<br><tt>mdn_nomemory</tt>
<p>

<dt><a name="mdn_translator_canonicalZLD">mdn_translator_canonicalZLD</a>
<dd>
<pre>
mdn_result_t
mdn_translator_canonicalZLD(const char *ZLD,
	char **canonicalizedp)
</pre>
<p>ZLD <var>ZLD</var> W`ɕϊÃ|C^
<var>canonicalizedp</var> ̎ẅɊi[܂B
ϊꂽ (<var>*canonicalizedp</var>) ̗̈
<em>malloc()</em> Ă܂̂ŁAsvɂȂ <em>free()</em> 
ĂB<br>
Converts ZLD <var>ZLD</var> to the standard format and stores a pointer in the area specified by <var>canonicalizedp</var>. Since the area for the converted character string (<var>*canonicalizedp</var>) is secured by <em>malloc()</em>, release it when it is no longer needed.
<p>ł ZLD ̕W`Ƃ͎̂悤Ȍ`̂̂w܂B<br>
The standard format for ZLD mentioned is as follows:
<ul>
<li>ZLD (""".") ̕W` NULL <br>
The standard format for empty ZLD ("" or ".") is NULL
<li>擪sIh (.) n܂Ă΃sIh <br>
The period is removed when the beginning is a period (.)
<li>ŌオsIh (.) ŏIĂȂ΃sIhlj <br>
A period is added when the ending is not a period (.)
<li>ׂ͂đ啶ɕϊ <br>
Lowercase characters are all converted to uppercase characters
<ul>
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_nomemory</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_nomemory</tt>
<p>

<dt><a name="mdn_translator_matchZLD">mdn_translator_matchZLD</a>
<dd>
<pre>
int
mdn_translator_matchZLD(const char *domain,
	const char *ZLD)
</pre>
<p>hC <var>domain</var>  ZLD <var>ZLD</var> }b`邩ǂ
𒲂ׁA}b`10Ԃ܂B<br>
Checks whether or not the <var>domain</var> variable and ZLD <var>ZLD</var> match, and returns a 1 if they match and a 0 if not.
<p>ZLD 
<a href="#mdn_translator_canonicalZLD"><em>mdn_translator_canonicalZLD</em></a>
ŕW`ɕϊ̂łȂ΂Ȃ܂B<br>
The ZLD must have been converted to the standard format by <a href="#mdn_translator_canonicalZLD"><em>mdn_translator_canonicalZLD</em></a>.

</dl>

<hr>

<h3><a name="unicode">unicode W[ <br>
unicode module</a></h3>

<p>unicode W[́A
<a href="ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt"><cite>UnicodeData.txt</cite></a>
ɋLqĂAUnicode ̊e핶擾郂W[łBȂA
Unicode.txt ɋLqĂf[^̈ӖAуt@C`ɂ‚Ă
<a href="ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.html"><cite>UnicodeData File Format</cite></a>B<br>
The unicode module obtains various character properties of Unicode described in <a href="ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt"><cite>UnicodeData.txt</cite></a>. For details of the data described in Unicode.txt and the file format, refer to <a href="ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.html"><cite>UnicodeData File Format</cite></a>.

<p>{Cȗ̃W[ Unicode ̃f[^ UTF-8GR[hꂽ
`ň܂ÃW[ <em>unsigned long</em> ^
f[^ƂĈ܂B܂܂l UCS-4 łB<br>
Many modules in this library handle Unicode data as UTF-8 encoded character strings but this module handles Unicode data as <em>unsigned long</em> type data. Includes UCS-4 values.

<p><a name="mdn__unicode_context_t">
̃W[ł Unicode ̑啶̑ݕϊ@\
񋟂Ă܂B</a> 
<a href="http://www.unicode.org/unicode/reports/tr21">
<cite>Unicode Technical Report #21: Case Mappings</cite></a> 
`Ă̂łB
Unicode ̒ɂ͂ꕔł啶̕ϊۂ
KvƂ̂Â͎悤ȗ񋓌^̃f[^Ŏw肵܂B<br><a name="mdn__unicode_context_t"> </a>This module provides a mutual conversion function between uppercase and lowercase Unicode characters. This is defined by <a href="http://www.unicode.org/unicode/reports/tr21">
<cite>Unicode Technical Report #21: Case Mappings</cite></a>.
Among Unicode characters, a few characters require context information when uppercase is converted to lowercase. This is specified by the following enumeration type data.
<blockquote>
<pre>
typedef enum {
	mdn__unicode_context_unknown,
	mdn__unicode_context_final,
	mdn__unicode_context_nonfinal
} mdn__unicode_context_t;
</pre>
</blockquote>
 FINAL ̏ꍇɂ <tt>mdn__unicode_context_final</tt> A܂
NON_FINAL ̏ꍇɂ <tt>mdn__unicode_context_nonfinal</tt> w肵܂B
<tt>mdn__unicode_context_unknown</tt> ͕񂪂킩Ȃ (ׂĂȂ)
Ƃ܂B
Ɋւďڂ͏LB<br>
When the context is FINAL, <tt>mdn__unicode_context_final</tt> is specified and when it is NON_FINAL, <tt>mdn__unicode_context_nonfinal</tt> is specified. <tt>mdn__unicode_context_unknown</tt> indicates that the context is unknown (has not yet been checked). For a detailed discussion of context information, refer to the above references.

<p>ȉɃW[̒񋟂API֐܂B<br>
This module provides the following API functions.

<dl>

<dt><a name="mdn__unicode_canonicalclass">mdn__unicode_canonicalclass</a>
<dd>
<pre>
int
mdn__unicode_canonicalclass(unsigned long c);
</pre>
<p>Unicode  <var>c</var>  <em>Canonical Combining Class</em> ߂܂B
Canonical Combining Class `ĂȂɂ‚Ă 0 Ԃ܂B<br>
Obtains <em>Canonical Combining Class</em> for Unicode character <var>c</var>.
0 is returned for characters for which Canonical Combining Class is not defined.
<p>

<dt><a name="mdn__unicode_decompose">mdn__unicode_decompose</a>
<dd>
<pre>
mdn_result_t
mdn__unicode_decompose(int compat,
	unsigned long *v, size_t vlen,
	unsigned long c, int *decomp_lenp)
</pre>
<p>Unicode  <var>c</var>  UnicodeData.txt <em>Character
Decomposition Mapping</em> ɂ decompose Ǎʂ
<var>v</var>  <var>vlen</var> Ŏw肳̈ɏ݂܂B
<var>compat</var> ̒l^Ȃ <em>Compatibility Decomposition</em> A
UȂ<em>Canonical Decomposition</em> s܂B<br>decompose ͍ċAIɍs܂B‚܂Character Decomposition Mappingɂĕeɂ‚Ă decompose s܂B<br>
<p>Decomposes Unicode characters <var>c</var> in accordance with <em>Character
Decomposition Mapping</em> of UnicodeData.txt and writes the result in the area specified by <var>v</var> and <var>vlen</var>. When the value of <var>compat</var> is true, <em>Compatibility Decomposition</em> is performed and when false, <em>Canonical Decomposition</em> is performed. Decompose is performed recursively, i.e. each character resolved in accordance with Character Decomposition Mapping is further decomposed.

<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_notfound</tt>A
<tt>mdn_nomemory</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_notfound</tt>
<br><tt>mdn_nomemory</tt>
<p>

<dt><a name="mdn__unicode_compose">mdn__unicode_compose</a>
<dd>
<pre>
mdn_result_t
mdn__unicode_compose(unsigned long c1,
	unsigned long c2, unsigned long *compp)
</pre>
<p><var>c1</var>  <var>c2</var> 2 Unicode ̃V[PX
UnicodeData.txt <em>Character Decomposition Mapping</em> ɂ
compose Ǎʂ <var>compp</var> ̎ẅɏ݂܂B
K <em>Canonical Composition</em> s܂B<br>
Composes a sequence of the two Unicode characters <var>c1</var> and <var>c2</var> per the <em>Character Decomposition Mapping</em> in UnicodeData.txt and writes the result in the area specified by <var>compp</var>. <em>Canonical Composition</em> is always peformed.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_notfound</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_notfound</tt>
<p>

<dt><a name="mdn__unicode_iscompositecandidate">mdn__unicode_iscompositecandidate</a>
<dd>
<pre>
int
mdn__unicode_iscompositecandidate(unsigned long c)
</pre>
<p>Unicode <var>c</var> n܂ Canonical Composition ݂邩
ǂ𒲂ׁA݂”\ 1 ”\Ȃ 0 Ԃ܂B
̓qgłA1ԂĂƂĂۂɂ Composition 
݂ȂƂ蓾܂Bt 0 ԂĂΊmɑ݂܂B<br>
Checks whether or not Canonical Composition that begins with Unicode character <var>c</var> exists. 1 is returned if existence is possible, and 0 if not. If 1 is returned, it is possible that Composition does not actually exist; however, when 0 is returned, it definitely does not exist.
<p>Unicode ̑S̒ Canonical Composition ̐擪ƂȂ镶͐
Ȃ̂ŁA<a href="#mdn__unicode_compose"><em>mdn__unicode_compose</em></a> ̌̃I[owbh炷߂ɂ炩߃f[^XN[jOړI
gp邱Ƃł܂B<br>
As there are only a small number of Unicode characters that can begin Canonical Composition, this can be used for pre-screening of data in order to decrease the search overhead of <a href="#mdn__unicode_compose"><em>mdn__unicode_compose</em></a>.
<p>

<dt><a name="mdn__unicode_toupper">mdn__unicode_toupper</a>
<dd>
<pre>
mdn_result_t
mdn__unicode_toupper(unsigned long c, mdn__unicode_context_t ctx,
	unsigned long *v, size_t vlen, int *convlenp)
</pre>
<p>Unicode <var>c</var>  UnicodeData.txt  <em>Uppercase Mapping</em>
񂨂 SpecialCasing.txt̏ɂđ啶ɕϊAʂ
<var>v</var> ̎ẅɊi[܂B<var>vlen</var> ͂炩
<var>v</var> Ɋmۂ̈̑傫łBϊʂ̕
<var>*convlenp</var> ɕԂ܂B
ϊʂ̕ɂȂ邱Ƃ邱ƂɒӂĂB
܂P[ˑ̕ϊ͍s܂B<br>
Converts Unicode characters <var>c</var> to uppercase in accordance with the <em>Uppercase Mapping</em> information in UnicodeData.txt and SpecialCasing.txt, and stores the result in the area specified by <var>v</var>. <var>vlen</var> is the size of the area that is secured for <var>v</var> beforehand. The number of characters in the conversion result is returned to <var>*convlenp</var>. Note that the conversion result may be greater than one character and that locale-dependent conversion is not performed.

<p><var>ctx</var> ͕ <var>c</var> ̏o
<a href="#mdn__unicode_context_t"></a>łB
قƂǂ̕ł͕ϊ̍ۂɕ͕svȂ߁A
ʏ <tt>mdn__unicode_context_unknown</tt> w肵ĂƂł܂B
񂪕KvȏꍇA{֐͖߂lƂ <tt>mdn_context_required</tt>
Ԃ̂ŁA擾Ă߂ČĂяoƂ”\łB
̎擾ɂ <a href="#mdn__unicode_getcontext">
<em>mdn__unicode_getcontext</em></a> gp܂B<br>
<var>ctx</var> is <a href="#mdn__unicode_context_t"> context information</a> where character <var>c</var> appears.
Since most characters do not require context information when they are converted, usually <tt>mdn__unicode_context_unknown</tt> can be specified.
When context information is necessary, this function returns <tt>mdn_context_required</tt> as the return value, and it is possible to call it again after obtaining the context information. To obtain context information, <a href="#mdn__unicode_getcontext"> <em>mdn__unicode_getcontext</em></a> is used.

<p>Ή啶݂Ȃꍇɂ <var>c</var> ̂܂
<var>v</var> Ɋi[܂B<br>
If no corresponding uppercase character exists, <var>c</var> is stored in <var>v</var> as is.

<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_context_required</tt>A
<tt>mdn_buffer_overflow</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_context_required</tt>
<br><tt>mdn_buffer_overflow</tt>
<p>

<dt><a name="mdn__unicode_tolower">mdn__unicode_tolower</a>
<dd>
<pre>
mdn_result_t
mdn__unicode_tolower(unsigned long c, mdn__unicode_context_t ctx,
	unsigned long *v, size_t vlen, int *convlenp)
</pre>
<p>Unicode <var>c</var>  UnicodeData.txt  <em>Uppercase Mapping</em>
񂨂 SpecialCasing.txt̏ɂďɕϊAʂ
<var>v</var> ̎ẅɊi[܂B<var>vlen</var> ͂炩
<var>v</var> Ɋmۂ̈̑傫łBϊʂ̕
<var>*convlenp</var> ɕԂ܂B
ϊʂ̕ɂȂ邱Ƃ邱ƂɒӂĂB
܂P[ˑ̕ϊ͍s܂B<br>
Converts Unicode character <var>c</var> to lowercase in accordance with <em>Uppercase Mapping</em> information of UnicodeData.txt and SpecialCasing.txt information, and stores the result in the area specified by <var>v</var>. <var>vlen</var> is the size of area that is secured for <var>v</var> beforehand. The number of characters of the conversion result is returned to <var>*convlenp</var>.

<p><var>ctx</var> ͕ <var>c</var> ̏o
<a href="#mdn__unicode_context_t"></a>łB
قƂǂ̕ł͕ϊ̍ۂɕ͕svȂ߁A
ʏ <tt>mdn__unicode_context_unknown</tt> w肵ĂƂł܂B
񂪕KvȏꍇA{֐͖߂lƂ <tt>mdn_context_required</tt>
Ԃ̂ŁA擾Ă߂ČĂяoƂ”\łB
̎擾ɂ <a href="#mdn__unicode_getcontext">
<em>mdn__unicode_getcontext</em></a> gp܂B<br>
<var>ctx</var> is <a href="#mdn__unicode_context_t"> context information</a> where character <var>c</var> appears.
Since most characters do not require context information when they are converted, usually <tt>mdn__unicode_context_unknown</tt> can be specified.
When context information is necessary, this function returns <tt>mdn_context_required</tt> as the return value, and it is possible to call it again after obtaining the context information.
To obtain context information, <a href="#mdn__unicode_getcontext">
<em>mdn__unicode_getcontext</em></a> is used.

<p>Ή鏬݂Ȃꍇɂ <var>c</var> ̂܂
<var>v</var> Ɋi[܂B<br>
If no corresponding uppercase character exists, <var>c</var> is stored in <var>v</var> as is.

<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_context_required</tt>A
<tt>mdn_buffer_overflow</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_context_required</tt>
<br><tt>mdn_buffer_overflow</tt>
<p>

<dt><a name="mdn__unicode_getcontext">mdn__unicode_getcontext</a>
<dd>
<pre>
mdn__unicode_context_t
mdn__unicode_getcontext(unsigned long c)
</pre>
<p>啶ϊŗp镶Ԃ܂B
擾ɂ͎̂悤ɂ܂B
܂啶ϊ̑Ώەɑ̕擾Å֐
Ăяo܂BԂl <tt>mdn__unicode_context_final</tt><tt>mdn__unicode_context_nonfinal</tt> ̂ꂩł
ꂪ߂镶łB
<tt>mdn__unicode_context_unknown</tt> ̏ꍇɂ͂ɑ擾A
̊֐Ăяo܂B̂悤ɂ <tt>mdn__unicode_context_final</tt>
 <tt>mdn__unicode_context_nonfinal</tt> ꂩ̒l܂
JԂ܂B̍Ō܂ŗꍇɂ́A<tt>mdn__unicode_context_final</tt> ƂȂ܂B<br>
Returns context information used for conversion of uppercase/lowercase characters.
To obtain context information, first the character following the uppercase/lowercase character conversion target character is obtained and this function is called. If the return value is <tt>mdn__unicode_context_final</tt> or <tt>mdn__unicode_context_nonfinal</tt>, that context information is the context information to obtain.
If <tt>mdn__unicode_context_unknown</tt> is returned, the next character is obtained and the function is called. In this way, processing continues until either the value of <tt>mdn__unicode_context_final</tt> or <tt>mdn__unicode_context_nonfinal</tt> is obtained. When processing reaches the end of the character string, <tt>mdn__unicode_context_final</tt> becomes the context.

<p>̓Iɂ͂̊֐͎̂悤ȏs܂B
Unicode  <var>c</var>  "General Category" QƂA
ꂪ "Lu" "Ll" "Lt" ̂ꂩł
<tt>mdn__unicode_context_nonfinal</tt> A"Mn" ł
<tt>mdn__unicode_context_unknown</tt> AȊOł
<tt>mdn__unicode_context_final</tt> Ԃ܂B<br>
Specifically, this function does the following.
Refers "General Category" properties of Unicode character <var>c</var> and if it is "Lu", "Ll" or "Lt" <tt>mdn__unicode_context_nonfinal</tt> is returned, if it is "Mn" <tt>mdn__unicode_context_unknown</tt> is returned, and if it is other than the above, <tt>mdn__unicode_context_final</tt> is returned.

</dl>

<hr>

<h3><a name="unormalize">unormalize W[ <br>
unormalize module</a></h3>

<p>unormalize W[́AUnicode Œ`ĂW̐K
sW[łBUnicode ̐K
<a href="http://www.unicode.org/unicode/reports/tr15"><cite>Unicode Technical Report #15: Unicode Normalization Forms</cite></a>
Œ`Ă܂B{W[͂̕ɂꂽ4‚̐K`
Ă܂B<br>
The unormalize module performs the standard normalization defined by Unicode. Normalization of Unicode is defined in <a href="http://www.unicode.org/unicode/reports/tr15"><cite>Unicode Technical Report #15: Unicode Normalization Forms</cite></a>. This module implements the four normalization forms mentioned in this document.

<p>ȉɃW[̒񋟂API֐܂B<br>
This module provides the following API functions.

<dl>

<dt><a name="mdn__unormalize_formc">mdn__unormalize_formc</a>
<dd>
<pre>
mdn_result_t
mdn__unormalize_formc(const char *from, char *to, size_t tolen)
</pre>
<p>UTF-8ŃGR[hꂽ <var>from</var> ɑ΂
K <em>Unicode Normalization Form C</em> KpǍʂ
<var>to</var>  <var>tolen</var> Ŏw肳̈ɏ݂܂B<br>
Applies <em>Unicode Normalization Form C</em> normalization to a UTF-8 encoded <var>from</var> character string and writes the result in the area specified by <var>to</var> and <var>tolen</var>.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_invalid_encoding</tt>A
<tt>mdn_buffer_overflow</tt>A
<tt>mdn_nomemory</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_invalid_encoding</tt>
<br><tt>mdn_buffer_overflow</tt>
<br><tt>mdn_nomemory</tt>
<p>

<dt><a name="mdn__unormalize_formd">mdn__unormalize_formd</a>
<dd>
<pre>
mdn_result_t
mdn__unormalize_formd(const char *from, char *to, size_t tolen)
</pre>
<p>UTF-8ŃGR[hꂽ <var>from</var> ɑ΂
K <em>Unicode Normalization Form D</em> KpǍʂ
<var>to</var>  <var>tolen</var> Ŏw肳̈ɏ݂܂B<br>
Applies <em>Unicode Normalization Form D</em> normalization to a UTF-8 encoded <var>from</var> character string and writes the result in the area specified by <var>to</var> and <var>tolen</var>.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_invalid_encoding</tt>A
<tt>mdn_buffer_overflow</tt>A
<tt>mdn_nomemory</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_invalid_encoding</tt>
<br><tt>mdn_buffer_overflow</tt>
<br><tt>mdn_nomemory</tt>
<p>

<dt><a name="mdn__unormalize_formkc">mdn__unormalize_formkc</a>
<dd>
<pre>
mdn_result_t
mdn__unormalize_formkc(const char *from, char *to, size_t tolen)
</pre>
<p>UTF-8ŃGR[hꂽ <var>from</var> ɑ΂
K <em>Unicode Normalization Form KC</em> KpǍʂ
<var>to</var>  <var>tolen</var> Ŏw肳̈ɏ݂܂B<br>
Applies <em>Unicode Normalization Form KC</em> normalization to a UTF-8 encoded <var>from</var> character string and writes the result in the area specified by <var>to</var> and <var>tolen</var>.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_invalid_encoding</tt>A
<tt>mdn_buffer_overflow</tt>A
<tt>mdn_nomemory</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_invalid_encoding</tt>
<br><tt>mdn_buffer_overflow</tt>
<br><tt>mdn_nomemory</tt>
<p>

<dt><a name="mdn__unormalize_formkd">mdn__unormalize_formkd</a>
<dd>
<pre>
mdn_result_t
mdn__unormalize_formkd(const char *from, char *to, size_t tolen)
</pre>
<p>UTF-8ŃGR[hꂽ <var>from</var> ɑ΂
K <em>Unicode Normalization Form KD</em> KpǍʂ
<var>to</var>  <var>tolen</var> Ŏw肳̈ɏ݂܂B<br>
Applies <em>Unicode Normalization Form KC</em> normalization to a UTF-8 encoded <var>from</var> character string and writes the result in the area specified by <var>to</var> and <var>tolen</var>.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_invalid_encoding</tt>A
<tt>mdn_buffer_overflow</tt>A
<tt>mdn_nomemory</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_invalid_encoding</tt>
<br><tt>mdn_buffer_overflow</tt>
<br><tt>mdn_nomemory</tt>
</dl>

<hr>

<h3><a name="utf5">utf5 W[ <br>
utf5 module</a></h3>

<p>utf5 W[̓hC̃GR[fBÖ‚Ƃ
ĂĂ
<a href="../../reference/draft/draft-jseng-utf5-01.txt">UTF-5 GR[fBO</a> 
̊{sW[łB<br>
The utf5 module performs basic processing for the proposed <a href="../../reference/draft/draft-jseng-utf5-01.txt">UTF-5 </a> domain name encoding system.

<p>ȉɃW[̒񋟂API֐܂B<br>
This module provides the following API functions.

<dl>

<dt><a name="mdn_utf5_getwc">mdn_utf5_getwc</a>
<dd>
<pre>
int
mdn_utf5_getwc(const char *s, size_t len,
	unsigned long *vp)
</pre>
<p>UTF-5ŃGR[hꂽ <var>len</var> oCg̕ <var>s</var> 
擪̕oAUCS-4 ɕϊ <var>vp</var> ̎ẅɊi[
ƂɁA (UTF-5GR[hł) oCgԂ܂B
 <var>len</var> Zĕ̓rŏIĂAGR[fBO
ԈĂꍇɂ 0 Ԃ܂B<br>
Extracts the leading character of length <var>len</var> byte UTF-5 encoded character string <var>s</var>, converts it to UCS-4 and stores it in the area specified by <var>vp</var> and also returns the number of bytes in the (UTF-5 encoded) character strintg. 0 is returned if <var>len</var> is too short and ends in the middle of a character or the encoding is invalid.
<p>

<dt><a name="mdn_utf5_putwc">mdn_utf5_putwc</a>
<dd>
<pre>
int
mdn_utf5_putwc(char *s, size_t len, unsigned long v)
</pre>
<p>UCS-4  <var>v</var> UTF-5GR[fBOɕϊA<var>s</var>
 <var>len</var> Ŏw肳̈ɏނƂƂɁA񂾃oCg
Ԃ܂B <var>len</var> Zď߂Ȃꍇɂ0Ԃ܂B<br>
Converts UCS-4 characters <var>v</var> to UTF-5 encoding, writes them in the area specified by <var>s</var> and <var>len</var> and returns the number of bytes written. 0 is returned if <var>len</var> is too short to write.
<p>UTF-5<strong>NULL ŏI[Ă܂</strong>B<br>
The written UTF-5 character string is <strong>not terminated with a NULL character</strong>.

</dl>

<hr>

<h3><a name="utf8">utf8 W[ <br>
utf8 module</a></h3>

<p>utf8 W[UTF-8 ŃGR[hꂽ̊{s
W[łB<br>
The utf8 module performs the basic processing of UTF-8 encoded character strings.

<p>ȉɃW[̒񋟂API֐܂B<br>
This module provides the following API functions.

<dl>

<dt><a name="mdn_utf8_mblen">mdn_utf8_mblen</a>
<dd>
<pre>
int
mdn_utf8_mblen(const char *s)
</pre>
<p>UTF-8  <var>s</var> ̐擪̒(oCg)Ԃ܂B
 <var>s</var> woCg UTF-8 ̐擪oCgƂĐȂ̂ł
ꍇɂ 0 Ԃ܂B<br>
Returns the length (number of bytes) of the leading character in the UTF-8 character string <var>s</var>. 0 is returned if the leading byte indicated by <var>s</var> is not valid for UTF-8.
<p>̊֐ <var>s</var> ̐擪oCĝ݂𒲂ׂĒԂ܂B
2oCgڈȍ~ɕsȃoCg”\݂܂Bɓr NULL oCg
”\̂ŁA<var>s</var>  UTF-8 ł邱Ƃmł
Ȃꍇɂ͋C‚Kv܂B<br>
This function returns the length by checking the leading byte of <var>s</var>; there is therefore a possibility of invalid byte in the 2nd and later byte. In particular, NULL bytes may exist in the middle, so you have to be careful when it is not certain that <var>s</var> is a valid UTF-8 character string.
<p>

<dt><a name="mdn_utf8_getmb">mdn_utf8_getmb</a>
<dd>
<pre>
int
mdn_utf8_getmb(const char *s, size_t len, char *buf)
</pre>
<p> <var>len</var> oCg UTF-8  <var>s</var> ̐擪1<var>buf</var> ɃRs[ARs[oCgԂ܂B <var>len</var> ZA<var>s</var> w UTF-8 ƂĐȂꍇɂ̓Rs[͍s킸A0 Ԃ܂B<br>
Copies the leading character of <var>s</var> UTF-8 character strings of length <var>len</var> and returns the number of copied bytes.
<p><var>buf</var> ͔Cӂ UTF-8 GR[fBO̕ێł傫
łȂ΂Ȃ܂BȂ킿A6oCgȏ̒ĂKv܂B<br>
<var>buf</var> must be large enough to hold any UTF-8 encoding, i.e. it must be 6 bytes or larger. 
<p>UTF-8 <strong>NULL ŏI[Ă܂</strong>B<br>
The written UTF-8 character string is <strong> not terminated with a NULL character</strong>.
<p>

<dt><a name="mdn_utf8_getwc">mdn_utf8_getwc</a>
<dd>
<pre>
int
mdn_utf8_getwc(const char *s, size_t len,
	unsigned long *vp)
</pre>
<p><a href="#mdn_utf8_getmb"><em>mdn_utf8_getmb</em></a> ƂقړłA
<var>s</var> o
UCS-4ɕϊ <var>vp</var> ̎ẅɊi[Ƃ낪قȂ܂B<br>
This is almost same as <a href="#mdn_utf8_getmb"><em>mdn_utf8_getmb</em></a> with the difference being that characters extracted from <var>s</var> are converted to UCS-4 and stored in the area indicated by <var>vp</var>.
<p>

<dt><a name="mdn_utf8_putwc">mdn_utf8_putwc</a>
<dd>
<pre>
int
mdn_utf8_putwc(char *s, size_t len, unsigned long v)
</pre>
<p>UCS-4  <var>v</var>  UTF-8 GR[fBOɕϊāA
<var>s</var>  <var>len</var> Ŏw肳̈ɏނƂƂɁA
񂾃oCgԂ܂B<var>v</var> ̒lsł
<var>len</var> Zꍇɂ 0 Ԃ܂B<br>
Converts UCS-4 character <var>v</var> to UTF-8 encoding, writes it in the area specified by <var>s</var> and <var>len</var> and returns the number of written bytes. 0 is returned when the value of <var>v</var> is invalid or <var>len</var> is too short.
<p>UTF-8 NULL ŏI[Ă܂</strong>B<br>
The written UTF-8 character string is <strong>not terminated with a NULL character</strong>.
<p>

<dt><a name="mdn_utf8_isvalidstring">mdn_utf8_isvalidstring</a>
<dd>
<pre>
int
mdn_utf8_isvalidstring(const char *s)
</pre>
<p>NULL ŏI[ꂽ <var>s</var>  UTF-8 GR[fBO
ł邩ǂׁA 10 Ԃ܂B<br>
Checks whether or not character string <var>s</var> terminated with a NULL character is valid UTF-8 encoding and returns 1 if so and 0 if not.
<p>

<dt><a name="mdn_utf8_findfirstbyte">mdn_utf8_findfirstbyte</a>
<dd>
<pre>
char *
mdn_utf8_findfirstbyte(const char *s,
	const char *known_top)
</pre>
<p> <var>known_top</var>  <var>s</var> woCg܂
UTF-8 ̐擪oCg𒲂ׂĕԂ܂B̕ UTF-8 
GR[fBOł͂ȂꍇA<var>known_top</var>  <var>s</var> ܂ł
Ԃɐ擪oCgȂꍇɂ NULL Ԃ܂B<br>
In the character string <var>known_top</var>, checks the leading byte of UTF-8 characters including the byte indicated by <var>s</var> and returns it. NULL is returned if there are any incorrectly encoded UTF-8 characters or there is no leading byte between <var>known_top</var> and <var>s</var>.

</dl>

<hr>

<h3><a name="util">util W[ util module</a></h3>

<p>util W[͑̃W[Ŏg郆[eBeB[I
@\񋟂郂W[łB
݂̂Ƃ͑啶̋ʂȂƍ̋@\݂̂
񋟂Ă܂B<br>
The util module provides utility type functions used by other modules. The only function currently provided is a character string collation function that does not differentiate between uppercase and lowercase characters.

<p>ȉɃW[̒񋟂API֐܂B<br>
This module provides the following API functions.

<dl>
<dt><a name="mdn_util_casematch">mdn_util_casematch</a>
<dd>
<pre>
int
mdn_util_casematch(const char *s1, const char *s2, size_t n)
</pre>
<p> <var>s1</var>  <var>s2</var> ̐擪ő <var>n</var> oCg
rAꂩǂ𔻒肵܂B
ASCII ̑啶Ə (‚܂ A  Z  a  z) ͓Ƃ݂Ȃ܂B
ł 10 Ԃ܂B
͑̃VXeŗpӂĂ <em>strcasencmp</em> ƕԂl̎dl
΂قړl̋@\񋟂֐łB<br>
Compares the maximum <var>n</var> bytes from the beginning of character strings <var>s1</var> and <var>s2</var> and determines whether or not they are identical. Uppercase and lowercase ASCII characters (i.e. A to Z and a to z) are assumed to be the same. 1 is returned if they are found to be identical and 0 is returned if not. With the exception of the return value specifications, this function provides almost the same features as <em>strcasencmp</em>, which is provided in many systems.
</dl>
<p>

<hr>

<h3><a name="ZLDrule">ZLDrule W[ ZLDrule module</a></h3>

<p>ZLDrule W[̓hC ZLD Ƃ̃}b`OsW[łB
hCɎgp”\̂ ZLD ̃XgƂꂼ ZLD ɑΉ
GR[fBÕXgA^ꂽhCƂ̃}b`Os
}b` ZLD ƃGR[fBOԂ܂B<br>
The ZLDrule module matches the domain name and ZLD. It has a list of ZLDs that are probably used for domain names and the list of encodings corresponding to each ZLD, and performs matching with the given doman name, then returns the matched ZLD and encoding.

<p>ZLDrule W[̓}b`Ô߂ɁuReLXgvƂTOp܂B
}b`Oɐ旧Ă܂ReLXg쐬Aɑ΂
ZLD ƃGR[fBOo^Ă܂B
ĎۂɃhCƃ}b`Osۂɂ͂̃ReLXgp
}b`OɎgpZLD ƃGR[fBÕXgw肵܂B
ReLXǧ^
<em>mdn_ZLDrule_t</em> ^łÂ悤 opaque ^ƂĒ`Ă܂B<br>
The ZLDrule module uses "context" concept for matching. Prior to matching, a context is created and ZLD and encoding are registered for the context. When domain name matching is performed, this context is used to specify the ZLD and encoding lists used for matching. The type of context is <em>mdn_ZLDrule_t</em> and is defined as the following opaque type.

<blockquote>
<pre>
typedef struct mdn_ZLDrule *mdn_ZLDrule_t;
</pre>
</blockquote>

<p>ȉɃW[̒񋟂API֐܂B<br>
This module provides the following API functions.

<dl>

<dt><a name="mdn_ZLDrule_create">mdn_ZLDrule_create</a>
<dd>
<pre>
mdn_result_t
mdn_ZLDrule_create(mdn_ZLDrule_t *ctxp)
</pre>
<p>ZLD̃}b`Os߂̃ReLXg쐬A
<var>ctxp</var> ̎ẅɊi[܂B<br>
Creates a context for ZLD matching and stores it in the area indicated by <var>ctxp</var>.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_nomemory</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_nomemory</tt>
<p>

<dt><a name="mdn_ZLDrule_destroy">mdn_ZLDrule_destroy</a>
<dd>
<pre>
void
mdn_ZLDrule_destroy(mdn_ZLDrule_t ctx)
</pre>
<p><a href="#mdn_ZLDrule_create"><em>mdn_ZLDrule_create</em></a> ō쐬
ReLXg <var>ctx</var> 폜Amۂ܂B<br>
Deletes the context created by <a href="#mdn_ZLDrule_create"><em>mdn_ZLDrule_create</em></a> and releases the allocated memory.
<p>

<dt><a name="mdn_ZLDrule_add">mdn_ZLDrule_add</a>
<dd>
<pre>
mdn_result_t
mdn_ZLDrule_add(mdn_ZLDrule_t ctx, const char *ZLD,
	const char **encodings, int nencodings)
</pre>
<p><a href="#mdn_ZLDrule_create"><em>mdn_ZLDrule_create</em></a> ō쐬
ReLXg <var>ctx</var> ɁAZLD <var>ZLD</var> 
<var>encodings</var>  <var>nencodings</var> Ŏw肳
GR[fBOXg̑go^܂B<br>
Registers the <var>ZLD</var> and encoding list set specified by <var>encodings</var> and <var>nencodings</var> in context <var>ctx</var> created by <a href="#mdn_ZLDrule_create"><em>mdn_ZLDrule_create</em></a>.
<p> ZLDA‚܂ ""  "." ͔Cӂ̃hCɃ}b`܂B
ZLDƂċ̒lw肷邱ƂɂāA
ZLD ɂ}b`Ȃꍇ̃ftHg̃GR[fBOw肷邱Ƃ
”\łB<br>
Empty ZLDs such as "" or "." match all domain names, therefore, by specifying an empty value for ZLD the default encoding can be specified in those cases in which no ZLD match is found.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_nomemory</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_nomemory</tt>
<p>

<dt><a name="mdn_ZLDrule_select">mdn_ZLDrule_select</a>
<dd>
<pre>
mdn_result_t
mdn_ZLDrule_select(mdn_ZLDrule_t ctx, const char *domain,
	char **ZLDp, mdn_converter_t *convctxp)
</pre>
<p>ReLXg <var>ctx</var> Ɋ܂܂Ă ZLD ̃Xg
hC <var>domain</var> Ƃ̃}b`O݂܂B}b`O
ZLD (ZLD \郉x̐) ̂珇ɍs܂B<br>
Attempts to match the ZLD list contained in context <var>ctx</var> and domain name <var>domain</var>. Matching is executed starting from the longest ZLD (a ZLD consisting of many labels).
<p>}b`ZLDꍇA<var>ZLDp</var> ̎ẅɁA}b`
ZLD ւ̃|C^i[܂BԂ|C^͂ł
<a href="#mdn_translator_canonicalZLD"><em>mdn_translator_canonicalZLD</em></a>
ɂĕW`ɂȂĂ̂ŁÂ܂
<a href="#mdn_translator_translate"><em>mdn_translator_translate</em></a> ւ
ƂēnƂł܂B<br>
When a ZLD match is found, the pointer to the ZLD match is stored in the area specified by <var>ZLDp</var>. Since the return pointer has already been converted to the standard form by <a href="#mdn_translator_canonicalZLD"><em>mdn_translator_canonicalZLD</em></a>, it can be passed as the argument as is.
<p>}b`ZLD ɑΉGR[fBO‚ȂÃGR[fBO
ɑΉR[hϊReLXg <var>convctxp</var> ̎ẅ
i[܂B
ΉGR[fBO΁AXg̐擪珇
<var>domain</var> ̃GR[fBOƂĐǂ𒲂ׂ܂B
̂΁AŏɌ‚̂̃R[hϊReLXg
<var>convctxp</var> ̎ẅɊi[܂B̂Ȃ
<var>convctxp</var> ɂ͉܂ꂸA<tt>mdn_invalid_encoding</tt>
Ԃ܂B<br>
When only one encoding method corresponds to the matched ZLD, the code conversion context corresponding to that encoding method is stored in the area specified by <var>convctxp</var>. If there is more than one valid encoding method, a check is performed from the top of the list to determine whether or not <var>domain</var> is valid for the encoding. Of the valid encoding methods found, the code conversion context of the first one found is stored in the area specified by <var>convctxp</var>. If no valid encoding method is found, nothing is written in <var>convctxp</var> and <tt>mdn_invalid_encoding</tt> is returned.
<p>}b` ZLD Ȃ <tt>mdn_notfound</tt>ԂďI܂B<br>When there is no ZLD match, <tt>mdn_notfound</tt> is returned and processing ends.
<p>Ԃl
<tt>mdn_success</tt>A
<tt>mdn_notfound</tt>A
<tt>mdn_invalid_encoding</tt>
̂ꂩłB
<p>One of the following values is returned:
<br><tt>mdn_success</tt>
<br><tt>mdn_notfound</tt>
<br><tt>mdn_invalid_encoding</tt>

</dl>

</body>
</html>