var util = require('util'), Match = require ('../match'); /** * This is a superclass for the individual detectors for * each of the detectable members of the ISO 2022 family * of encodings. */ function ISO_2022() {}; ISO_2022.prototype.match = function(det) { /** * Matching function shared among the 2022 detectors JP, CN and KR * Counts up the number of legal an unrecognized escape sequences in * the sample of text, and computes a score based on the total number & * the proportion that fit the encoding. * * * @param text the byte buffer containing text to analyse * @param textLen the size of the text in the byte. * @param escapeSequences the byte escape sequences to test for. * @return match quality, in the range of 0-100. */ var i, j; var escN; var hits = 0; var misses = 0; var shifts = 0; var quality; // TODO: refactor me // int match(byte [] text, int textLen, byte [][] escapeSequences) { // det.fInputBytes, det.fInputLen var text = det.fInputBytes; var textLen = det.fInputLen; scanInput: for (i=0; i