This code:

1390     } elseif {[regexp {shift[-_]?js} $charset]} {
1391         set encoding "shiftjis"

looks like shiftjis is misspelled in the regexp. If it isn't, the code should be commented accordingly