Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch tip607-encoding-failindex Excluding Merge-Ins
This is equivalent to a diff from e79940819f to 61b6543b0f
2022-07-02
| ||
19:39 | TIP #607: -failindex option for encoding convertto/convertfrom check-in: 2c4329d1a2 user: jan.nijtmans tags: core-8-branch | |
2022-06-19
| ||
20:23 | Fix TIP #312 documentation. Backported from [9c4dcc7347e8ef51] check-in: eee192b777 user: jan.nijtmans tags: core-8-branch | |
05:42 | Create new branch named "win-console" check-in: c24c8ab617 user: apnadkarni tags: win-console | |
2022-06-15
| ||
20:49 | Merge 8.7 Closed-Leaf check-in: 61b6543b0f user: jan.nijtmans tags: tip607-encoding-failindex | |
15:12 | (experimental) TclOO > 2**31 args check-in: 39a1dece8e user: jan.nijtmans tags: tcloo-64bit | |
12:24 | Merge 8.7 check-in: 339b37bab3 user: jan.nijtmans tags: tip-627 | |
12:17 | Merge-mark check-in: 57690dd1e0 user: jan.nijtmans tags: trunk, main | |
12:15 | Add comments in tcl.decls check-in: e79940819f user: jan.nijtmans tags: core-8-branch | |
10:04 | Backport tclStubLib.c from Tcl 9.0 (they should be equal in 8.7 and 9.0) check-in: df78bed29c user: jan.nijtmans tags: core-8-branch | |
2022-03-21
| ||
14:42 | Merge 8.7. Renumber testcases in cmdAH.test. check-in: affc202d27 user: jan.nijtmans tags: tip607-encoding-failindex | |
Changes to doc/encoding.n.
︙ | |||
10 11 12 13 14 15 16 | 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 | - + - - + + - - - - - - - + + - - + + - - - + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + | .SH NAME encoding \- Manipulate encodings .SH SYNOPSIS \fBencoding \fIoption\fR ?\fIarg arg ...\fR? .BE .SH INTRODUCTION .PP |
︙ | |||
86 87 88 89 90 91 92 93 94 95 96 97 98 99 | 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 | + + + + + + + + + + + + + + + + + + + + | .CS set s [\fBencoding convertfrom\fR euc-jp "\exA4\exCF"] .CE .PP The result is the unicode codepoint: .QW "\eu306F" , which is the Hiragana letter HA. .PP The following example detects the error location in an incomplete UTF-8 sequence: .PP .CS % set s [\fBencoding convertfrom\fR -failindex i utf-8 "A\xc3"] A % set i 1 .CE .PP The following example detects the error location while transforming to ISO8859-1 (ISO-Latin 1): .PP .CS % set s [\fBencoding convertto\fR -failindex i utf-8 "A\u0141"] A % set i 1 .CE .PP .SH "SEE ALSO" Tcl_GetEncoding(3) .SH KEYWORDS encoding, unicode .\" Local Variables: .\" mode: nroff .\" End: |
Changes to generic/tclCmdAH.c.
︙ | |||
552 553 554 555 556 557 558 559 560 561 562 | 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 | + + + + + + + + + + + - + + + + + + - - - - + + + + + + + + + + + + - - + + - - - - + - - + + + - + - + + + + + - - - - - - - - + + + + + + + + + + + + + | const char *bytesPtr; /* Pointer to the first byte of the array */ #if TCL_MAJOR_VERSION > 8 || defined(TCL_NO_DEPRECATED) int flags = TCL_ENCODING_STOPONERROR; #else int flags = TCL_ENCODING_NOCOMPLAIN; #endif int result; Tcl_Obj *failVarObj = NULL; /* * Decode parameters: * Possible combinations: * 1) data -> objc = 2 * 2) encoding data -> objc = 3 * 3) -nocomplain data -> objc = 3 * 4) -nocomplain encoding data -> objc = 4 * 5) -failindex val data -> objc = 4 * 6) -failindex val encoding data -> objc = 5 */ if (objc == 2) { encoding = Tcl_GetEncoding(interp, NULL); data = objv[1]; |
︙ | |||
655 656 657 658 659 660 661 662 663 664 665 | 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 | + + + + + + + + + + + + - + + + + + + - - - - + + + + + + + + + + + + - - + + - - - - + - - + + + - + - + + + + + + - - - - - - - - - - - + + + + + + + + + + + + + + + + | const char *stringPtr; /* Pointer to the first byte of the string */ int result; #if TCL_MAJOR_VERSION > 8 || defined(TCL_NO_DEPRECATED) int flags = TCL_ENCODING_STOPONERROR; #else int flags = TCL_ENCODING_NOCOMPLAIN; #endif Tcl_Obj *failVarObj = NULL; /* * Decode parameters: * Possible combinations: * 1) data -> objc = 2 * 2) encoding data -> objc = 3 * 3) -nocomplain data -> objc = 3 * 4) -nocomplain encoding data -> objc = 4 * 5) -failindex val data -> objc = 4 * 6) -failindex val encoding data -> objc = 5 */ if (objc == 2) { encoding = Tcl_GetEncoding(interp, NULL); data = objv[1]; |
︙ |
Changes to tests/cmdAH.test.
︙ | |||
174 175 176 177 178 179 180 | 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | - + | encoding } -result {wrong # args: should be "encoding subcommand ?arg ...?"} test cmdAH-4.2 {Tcl_EncodingObjCmd} -returnCodes error -body { encoding foo } -result {unknown or ambiguous subcommand "foo": must be convertfrom, convertto, dirs, names, or system} test cmdAH-4.3 {Tcl_EncodingObjCmd} -returnCodes error -body { encoding convertto |
︙ | |||
196 197 198 199 200 201 202 | 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | - + | encoding system iso8859-1 encoding convertto jis0208 乎 } -cleanup { encoding system $system } -result 8C test cmdAH-4.7 {Tcl_EncodingObjCmd} -returnCodes error -body { encoding convertfrom |
︙ | |||
230 231 232 233 234 235 236 237 238 239 240 241 242 243 | 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 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | set system [encoding system] } -body { encoding system iso8859-1 encoding system } -cleanup { encoding system $system } -result iso8859-1 test cmdAH-4.14.1 {Syntax error, -nocomplain and -failindex, no encoding} -body { encoding convertfrom -nocomplain -failindex 2 ABC } -returnCodes 1 -result {wrong # args: should be "encoding convertfrom ?-nocomplain? ?-failindex var? ?encoding? data"} test cmdAH-4.14.2 {Syntax error, -nocomplain and -failindex, no encoding} -body { encoding convertto -nocomplain -failindex 2 ABC } -returnCodes 1 -result {wrong # args: should be "encoding convertto ?-nocomplain? ?-failindex var? ?encoding? data"} test cmdAH-4.15.1 {Syntax error, -failindex and -nocomplain, no encoding} -body { encoding convertfrom -failindex 2 -nocomplain ABC } -returnCodes 1 -result {unknown encoding "-nocomplain"} test cmdAH-4.15.2 {Syntax error, -failindex and -nocomplain, no encoding} -body { encoding convertto -failindex 2 -nocomplain ABC } -returnCodes 1 -result {unknown encoding "-nocomplain"} test cmdAH-4.16.1 {Syntax error, -nocomplain and -failindex, encoding} -body { encoding convertfrom -nocomplain -failindex 2 utf-8 ABC } -returnCodes 1 -result {wrong # args: should be "encoding convertfrom ?-nocomplain? ?-failindex var? ?encoding? data"} test cmdAH-4.16.2 {Syntax error, -nocomplain and -failindex, encoding} -body { encoding convertto -nocomplain -failindex 2 utf-8 ABC } -returnCodes 1 -result {wrong # args: should be "encoding convertto ?-nocomplain? ?-failindex var? ?encoding? data"} test cmdAH-4.17.1 {Syntax error, -failindex and -nocomplain, encoding} -body { encoding convertfrom -failindex 2 -nocomplain utf-8 ABC } -returnCodes 1 -result {wrong # args: should be "encoding convertfrom ?-nocomplain? ?-failindex var? ?encoding? data"} test cmdAH-4.17.2 {Syntax error, -failindex and -nocomplain, encoding} -body { encoding convertto -failindex 2 -nocomplain utf-8 ABC } -returnCodes 1 -result {wrong # args: should be "encoding convertto ?-nocomplain? ?-failindex var? ?encoding? data"} test cmdAH-4.18.1 {Syntax error, -failindex with no var, no encoding} -body { encoding convertfrom -failindex ABC } -returnCodes 1 -result {wrong # args: should be "::tcl::encoding::convertfrom ?-nocomplain? ?-failindex var? ?encoding? data"} test cmdAH-4.18.2 {Syntax error, -failindex with no var, no encoding (byte compiled)} -setup { proc encoding_test {} { encoding convertfrom -failindex ABC } } -body { # Compile and execute encoding_test } -returnCodes 1 -result {wrong # args: should be "::tcl::encoding::convertfrom ?-nocomplain? ?-failindex var? ?encoding? data"} -cleanup { rename encoding_test "" } test cmdAH-4.18.3 {Syntax error, -failindex with no var, no encoding} -body { encoding convertto -failindex ABC } -returnCodes 1 -result {wrong # args: should be "::tcl::encoding::convertto ?-nocomplain? ?-failindex var? ?encoding? data"} test cmdAH-4.18.4 {Syntax error, -failindex with no var, no encoding (byte compiled)} -setup { proc encoding_test {} { encoding convertto -failindex ABC } } -body { # Compile and execute encoding_test } -returnCodes 1 -result {wrong # args: should be "::tcl::encoding::convertto ?-nocomplain? ?-failindex var? ?encoding? data"} -cleanup { rename encoding_test "" } test cmdAH-4.19.1 {convertrom -failindex with correct data} -body { encoding convertfrom -failindex test ABC set test } -returnCodes 0 -result -1 test cmdAH-4.19.2 {convertrom -failindex with correct data (byt compiled)} -setup { proc encoding_test {} { encoding convertfrom -failindex test ABC set test } } -body { # Compile and execute encoding_test } -returnCodes 0 -result -1 -cleanup { rename encoding_test "" } test cmdAH-4.19.3 {convertrom -failindex with correct data} -body { encoding convertto -failindex test ABC set test } -returnCodes 0 -result -1 test cmdAH-4.19.4 {convertrom -failindex with correct data (byt compiled)} -setup { proc encoding_test {} { encoding convertto -failindex test ABC set test } } -body { # Compile and execute encoding_test } -returnCodes 0 -result -1 -cleanup { rename encoding_test "" } test cmdAH-4.20.1 {convertrom -failindex with incomplete utf8} -body { set x [encoding convertfrom -failindex i utf-8 A\xc3] binary scan $x H* y list $y $i } -returnCodes 0 -result {41c3 -1} test cmdAH-4.20.2 {convertrom -failindex with incomplete utf8 (byte compiled)} -setup { proc encoding_test {} { set x [encoding convertfrom -failindex i utf-8 A\xc3] binary scan $x H* y list $y $i } } -body { # Compile and execute encoding_test } -returnCodes 0 -result {41c3 -1} -cleanup { rename encoding_test "" } test cmdAH-4.21.1 {convertto -failindex with wrong character} -body { set x [encoding convertto -failindex i iso8859-1 A\u0141] binary scan $x H* y list $y $i } -returnCodes 0 -result {41 1} test cmdAH-4.21.2 {convertto -failindex with wrong character (byte compiled)} -setup { proc encoding_test {} { set x [encoding convertto -failindex i iso8859-1 A\u0141] binary scan $x H* y list $y $i } } -body { # Compile and execute encoding_test } -returnCodes 0 -result {41 1} -cleanup { rename encoding_test "" } test cmdAH-5.1 {Tcl_FileObjCmd} -returnCodes error -body { file } -result {wrong # args: should be "file subcommand ?arg ...?"} test cmdAH-5.2 {Tcl_FileObjCmd} -returnCodes error -body { file x } -result {unknown or ambiguous subcommand "x": must be atime, attributes, channels, copy, delete, dirname, executable, exists, extension, isdirectory, isfile, join, link, lstat, mkdir, mtime, nativename, normalize, owned, pathtype, readable, readlink, rename, rootname, separator, size, split, stat, system, tail, tempdir, tempfile, type, volumes, or writable} |
︙ |
Changes to tests/encoding.test.
︙ | |||
665 666 667 668 669 670 671 | 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 | - + - + | string length [encoding convertfrom -nocomplain "\x20"] } 1 test encoding-24.21 {Parse with -nocomplain but without providing encoding} { string length [encoding convertto -nocomplain "\x20"] } 1 test encoding-24.22 {Syntax error, two encodings} -body { encoding convertfrom iso8859-1 utf-8 "ZX\uD800" |
︙ |
Changes to tests/safe.test.
︙ | |||
1265 1266 1267 1268 1269 1270 1271 | 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 | - + - + - + - + | } -result foobar test safe-11.7 {testing safe encoding} -setup { set i [safe::interpCreate] } -body { interp eval $i encoding convertfrom } -returnCodes error -cleanup { safe::interpDelete $i |
︙ |