--------------------------------------------------------------------------- fio.decodeBorderAns() 問題・回答の境界線のデコードを行う fio.encodeBorderAns() 問題・回答の境界線のエンコードを行う ---------------------------------------------------------------------------
541469
function(){
		this.decodeBorder( function(border,ca){
			if     (ca==="2" ){ border.qans = 1; border.qsub = 1;}
			else if(ca==="1" ){ border.qans = 1;}
			else if(ca==="-1"){ border.qsub = 1;}
		});
	}
589586
function encode(decoded, stack) {
    if (!stack) stack = [];

    if (decoded === undefined) return transferableUndefined;
    if (decoded === null) return null;

    var type = typeof(decoded);

    if (type === 'boolean') return decoded;
    if (type === 'string') return decoded;
    if (type === 'function') return { "!$function$!": decoded.toString() };

    if (type === 'number') {
      if (isNaN(decoded)) {
        return transferableNotANumber;
      } else {
        return decoded;
      }
    }

    if (type === 'object') {

      /* Proxy references */
      if (decoded.hasOwnProperty('!$proxyId$!')) {
        return { "!$proxyId$!": decoded['!$proxyId$!'] };
      }

      /* ArrayBuffers, views, dates, regular expressions, ... */
      if (isBufferOrView(decoded)) return encodeBufferOrView(decoded);
      if (decoded instanceof Date) return transferDate(decoded);
      if (decoded instanceof RegExp) return transferRegExp(decoded);

      /* Error object */
      if (decoded instanceof Error) {
        var name = decoded.name || Object.getPrototypeOf(decoded).name;
        var message = decoded.message;
        var stack = decoded.stack;
        var error = {};
        if (name) error.name = name;
        if (message) error.message = message;
        if (stack) error.stack = stack;
        return { "!$error$!": error };
      }

      /* Normal arrays and arrays from arguments calls */
      if ((decoded.hasOwnProperty('callee') && (typeof(decoded.length) === 'number'))
          || Array.isArray(decoded)) {
        return copy(decoded, [], stack, encode);
      }

      /* Other (normal) object */
      return copy(decoded, {}, stack, encode);

    }

    throw new Error("Unable to transfer " + type);
  }
52453
@Override
    public int decode ( byte[] buffer, int bufferIndex, int len ) throws SMBProtocolDecodingException {
        if ( this.largeFile ) {
            this.pid = SMBUtil.readInt2(buffer, bufferIndex);
            int boHigh = SMBUtil.readInt4(buffer, bufferIndex + 4);
            int boLow = SMBUtil.readInt4(buffer, bufferIndex + 8);

            this.byteOffset = ( boHigh << 32 ) | boLow;

            int lHigh = SMBUtil.readInt4(buffer, bufferIndex + 12);
            int lLow = SMBUtil.readInt4(buffer, bufferIndex + 16);

            this.lengthInBytes = ( lHigh << 32 ) | lLow;
            return 20;
        }
        this.pid = SMBUtil.readInt2(buffer, bufferIndex);
        this.byteOffset = SMBUtil.readInt4(buffer, bufferIndex + 2);
        this.lengthInBytes = SMBUtil.readInt4(buffer, bufferIndex + 6);
        return 10;
    }
88868
function b64DecodeUnicode(str) {
  // Going backwards: from bytestream, to percent-encoding, to original string.
  return decodeURIComponent(atob(str).split('').map(function (c) {
    return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
  }).join(''));
}
1154803
function decoder(mtype) {
  const gen = util.codegen([ 'r', 'l' ], mtype.name + '$decode')('if(!(r instanceof Reader))')('r=Reader.create(r)')('var c=l===undefined?r.len:r.pos+l,m=new this.ctor' + (mtype.fieldsArray.filter(field => field.map).length ? ',k' : ''))('while(r.pos<c){')('var t=r.uint32()');

  if (mtype.group) {
    gen('if((t&7)===4)')('break');
  }
  gen('switch(t>>>3){');

  for (let i = 0; i < /* initializes */ mtype.fieldsArray.length; ++i) {
    const field = mtype._fieldsArray[i].resolve();
    const type = field.resolvedType instanceof Enum ? 'int32' : field.type;
    const ref = 'm' + util.safeProp(field.name);
    gen('case %i:', field.id);

    // Map fields
    if (field.map) {
      gen('r.skip().pos++')('if(%s===util.emptyObject)', ref)('%s=new Map()', ref)('k=r.%s()', field.keyType)('r.pos++'); // assumes id 2 + value wireType
      // NOTE: 原来这里将 Long 对象转换成 hash 字符串是因为 Object 的 key 只能是字符串，现在用 Map 来实现后就让它原样输出就好了
      // if (types.long[field.keyType] !== undefined) {
      //   if (types.basic[type] === undefined) {
      //     gen('%s.set(typeof k==="object"?util.longToHash(k):k, types[%i].decode(r,r.uint32()));', ref, i); // can't be groups
      //   } else {
      //     gen('%s.set(typeof k==="object"?util.longToHash(k):k, r.%s());', ref, type);
      //   }
      // } else {
      if (types.basic[type] === undefined) {
        gen('%s.set(k, types[%i].decode(r,r.uint32()));', ref, i); // can't be groups
      } else {
        gen('%s.set(k, r.%s());', ref, type);
      }
      // }
      // Repeated fields
    } else if (field.repeated) {
      gen('if(!(%s&&%s.length))', ref, ref)('%s=[]', ref);

      // Packable (always check for forward and backward compatiblity)
      if (types.packed[type] !== undefined) {
        gen('if((t&7)===2){')('var c2=r.uint32()+r.pos')('while(r.pos<c2)')('%s.push(r.%s())', ref, type)('}else');
      }

      // Non-packed
      if (types.basic[type] === undefined) {
        gen(field.resolvedType.group ? '%s.push(types[%i].decode(r))' : '%s.push(types[%i].decode(r,r.uint32()))', ref, i);
      } else {
        gen('%s.push(r.%s())', ref, type);
      }
      // Non-repeated
    } else if (types.basic[type] === undefined) {
      gen(field.resolvedType.group ? '%s=types[%i].decode(r)' : '%s=types[%i].decode(r,r.uint32())', ref, i);
    } else {
      gen('%s=r.%s()', ref, type);
    }
    gen('break');
    // Unknown fields
  }
  gen('default:')('r.skipType(t&7)')('break')('}')('}');

  // Field presence
  for (let i = 0; i < mtype._fieldsArray.length; ++i) {
    const rfield = mtype._fieldsArray[i];
    if (rfield.required) {
      gen('if(!m.hasOwnProperty(%j))', rfield.name)('throw util.ProtocolError(%j,{instance:m})', missing(rfield));
    }
  }

  return gen('return m');
}
110562
function Decoder() {
    var skip = 0 // how many bits we have from the previous character
    var byte = 0 // current byte we're producing

    this.output = ''

    // Consume a character from the stream, store
    // the output in this.output. As before, better
    // to use update().
    this.readChar = function(char) {
        if (typeof char != 'string'){
            if (typeof char == 'number') {
                char = String.fromCharCode(char)
            }
        }
        char = char.toLowerCase()
        var val = lookup()[char]
        if (typeof val == 'undefined') {
            // character does not exist in our lookup table
            return // skip silently. An alternative would be:
            // throw Error('Could not find character "' + char + '" in lookup table.')
        }
        val <<= 3 // move to the high bits
        byte |= val >>> skip
        skip += 5
        if (skip >= 8) {
            // we have enough to preduce output
            this.output += String.fromCharCode(byte)
            skip -= 8
            if (skip > 0) byte = (val << (5 - skip)) & 255
            else byte = 0
        }

    }

    this.finish = function(check) {
        var output = this.output + (skip < 0 ? alphabet[bits >> 3] : '') + (check ? '$' : '')
        this.output = ''
        return output
    }
}
1109657
int decode(Buffer b) {
        int ptr = 0;
        DecodeAux t = decode_tree;
        int lok = b.look(t.tabn);

        if (lok >= 0) {
            ptr = t.tab[lok];
            b.adv(t.tabl[lok]);
            if (ptr <= 0) {
                return -ptr;
            }
        }
        do {
            switch (b.read1()) {
                case 0:
                    ptr = t.ptr0[ptr];
                    break;
                case 1:
                    ptr = t.ptr1[ptr];
                    break;
                case -1:
                default:
                    return (-1);
            }
        } while (ptr > 0);
        return (-ptr);
    }
1258319
function decode(encoded, stack) {
    if (!stack) stack = [];

    if (encoded === undefined) return undefined;
    if (encoded === null) return null;

    var type = typeof(encoded);

    if (type === 'boolean') return encoded;
    if (type === 'number') return encoded;
    if (type === 'string') return encoded;

    if (type === 'object') {

      /* Native transfer of ArrayBuffer(s), views, dates, regular expressions */
      if (isBufferOrView(encoded)) return encoded;
      if (encoded instanceof Date) return encoded;
      if (encoded instanceof RegExp) return encoded;

      /* Errors */
      if (encoded["!$error$!"] != null) {
        return new RemoteError(encoded["!$error$!"]);
      }

      /* Functions */
      if (encoded["!$function$!"] != null) {
        return eval('(' + encoded["!$function$!"] + ')');
      }

      /* Native transfers */
      if (encoded["!$native$!"] != null) {
        return receiveNative(encoded["!$native$!"]);
      }

      /* Proxy references */
      if (encoded["!$proxyId$!"] != null) {
        return getProxy(encoded["!$proxyId$!"]);
      }

      /* Other (normal) object and arrays */
      return copy(encoded, encoded, stack, decode);
    }

    throw new TypeError("Error decoding " + type + ": " + JSON.stringify(encoded));
  }
854976
public void decodeBulk(byte[][] readBufs, byte[][] writeBufs,
      int[] erasedLocations) throws IOException {
    int[] tmpInput = new int[readBufs.length];
    int[] tmpOutput = new int[erasedLocations.length];

    int numBytes = readBufs[0].length;
    for (int idx = 0; idx < numBytes; idx++) {
      for (int i = 0; i < tmpOutput.length; i++) {
        tmpOutput[i] = 0;
      }
      for (int i = 0; i < tmpInput.length; i++) {
        tmpInput[i] = readBufs[i][idx] & 0x000000FF;
      }
      decode(tmpInput, erasedLocations, tmpOutput);
      for (int i = 0; i < tmpOutput.length; i++) {
        writeBufs[i][idx] = (byte) tmpOutput[i];
      }
    }
  }
971747
function makeDecoder(chunkType) {
	if (chunkType === BUFFER) {
		return function (buf) {
			return buf.toString('utf8');
		};
	}
	if (isnode) {
		return function (a) {
			return new Buffer(a).toString('utf8');
		};
	}
	var decoder = null;
	return function (buf) {
		if (!decoder) {
			decoder = new TextDecoder();
		}
		return decoder.decode(buf);
	};
}
800567
function decodeBER($encoded)
    {
        if ($encoded instanceof Element) {
            $encoded = $encoded->element;
        }

        $this->encoded = $encoded;
        // encapsulate in an array for BC with the old decodeBER
        return array($this->_decode_ber($encoded));
    }
1300900
private List<GroupState> decode(byte[] bs, Charset charset) throws IOException {
        // 获取对象转换定义
        ObjectMetaData objectMetaData = FdfsParamMapper.getObjectMap(GroupState.class);
        int fixFieldsTotalSize = objectMetaData.getFieldsFixTotalSize();
        if (bs.length % fixFieldsTotalSize != 0) {
            throw new IOException("byte array length: " + bs.length + " is invalid!");
        }
        // 计算反馈对象数量
        int count = bs.length / fixFieldsTotalSize;
        int offset = 0;
        List<GroupState> results = new ArrayList<GroupState>(count);

        for (int i = 0; i < count; i++) {
            byte[] one = new byte[fixFieldsTotalSize];
            System.arraycopy(bs, offset, one, 0, fixFieldsTotalSize);
            results.add(FdfsParamMapper.map(one, GroupState.class, charset));
            offset += fixFieldsTotalSize;
        }

        return results;
    }
258342
function(){
		var lines = this.fstr.split("\n");
		var firstline = lines.shift();
		delete this.fstr;
		
		/* ヘッダからパズルの種類・ファイルの種類を判定する */
		if(firstline.match(/^pzprv3/)){
			this.type = FILE_PZPR;
			if(firstline.match(/pzprv3\.(\d+)/)){ this.filever = +RegExp.$1;}
			this.pid = lines.shift();
			this.qdata = lines.join("\n");
		}
		else if(firstline.match(/^\<\?xml/)){ // jshint ignore:line
			this.type = FILE_PBOX_XML;
			lines.unshift(firstline);
			this.qdata = lines.join("\n");
			if(!!DOMParser){
				this.body = (new DOMParser()).parseFromString(this.qdata, 'text/xml');
				this.pid = this.body.querySelector('puzzle').getAttribute('type');
			}
			else{ this.pid = '';}
		}
		else if(firstline.match(/^\d+$/)){
			this.type = FILE_PBOX;
			lines.unshift(firstline);
			this.qdata = lines.join("\n");
		}
		else{
			this.pid = '';
		}
		this.pid = pzpr.variety.toPID(this.pid);
		
		return (!!this.pid);
	}
598118
function(){
		this.decodeBorder( function(border,ca){
			if     (ca==="-1"){ border.qsub = 2;}
			else if(ca!=="0" ){ border.line = +ca;}
		});
	}
649748
function decode(buffer, encoding) {
		validateEncoding(encoding);
		if (encoding === null || encoding === 'buffer') return [buffer, new Buffer(0)];
		var decoder = new StringDecoder(encoding);
		var str = decoder.write(buffer);
		var leftover = decoder.charBuffer.slice(0, decoder.charReceived);
		return [str, leftover];
	}
453070
function decodeFromReader (reader, opts, cb) {
  if (typeof opts === 'function') {
    cb = opts
    opts = {}
  }

  _decodeFromReader(reader, opts, function onComplete (err, msg) {
    if (err) {
      if (err === true) return cb(new Error('Unexpected end of input from reader.'))
      return cb(err)
    }
    cb(null, msg)
  })
}
961075
@Override
	protected int decode(ByteBuffer b, char[] chars, int pos, int len, MutableBoolean interrupt, int min) {
		if (b == null) {
			// end
			if (state == 0)
				return -1;
			chars[pos] = (char)val;
			state = 0;
			return 1;
		}
		int nb = 0;
		while ((state == 7 || b.hasRemaining()) && nb < len && (nb < min || interrupt == null || !interrupt.get())) {
			int a = state == 7 ? 0 : b.get() & 0xFF;
			switch (state) {
			case 0:
				if (a < 0x80) {
					// 0aaa aaaa
					chars[pos + (nb++)] = (char)a;
				} else if ((a & 0xE0) == 0xC0) {
					// 110a aaaa 10bb bbbb
					val = (a & 0x1F) << 6;
					state = 1;
				} else if ((a & 0xF0) == 0xE0) {
					// 1110 aaaa 10bb bbbb 10cc cccc
					val = (a & 0x0F) << 12;
					state = 2;
				} else if ((a & 0xF8) == 0xF0) {
					// 1111 0aaa 10bb bbbb 10cc cccc 10dd dddd
					val = (a & 0x07) << 12;
					state = 4;
				} else {
					chars[pos + (nb++)] = invalidChar;
				}
				break;
			case 1:
				// second byte of 110a aaaa 10bb bbbb
				if ((a & 0xC0) == 0x80) {
					chars[pos + (nb++)] = (char)(val | (a & 0x3F));
				} else {
					chars[pos + (nb++)] = invalidChar;
				}
				state = 0;
				break;
			case 2:
				// second byte of 1110 aaaa 10bb bbbb 10cc cccc
				if ((a & 0xC0) == 0x80) {
					val |= (a & 0x3F) << 6;
					state = 3;
				} else {
					chars[pos + (nb++)] = invalidChar;
					state = 0;
				}
				break;
			case 3:
				// third byte of 1110 aaaa 10bb bbbb 10cc cccc
				if ((a & 0xC0) == 0x80) {
					chars[pos + (nb++)] = (char)(val | (a & 0x3F));
				} else {
					chars[pos + (nb++)] = invalidChar;
				}
				state = 0;
				break;
			case 4:
				// second byte of 1111 0aaa 10bb bbbb 10cc cccc 10dd dddd
				if ((a & 0xC0) == 0x80) {
					val |= (a & 0x3F) << 6;
					state = 5;
				} else {
					chars[pos + (nb++)] = invalidChar;
					state = 0;
				}
				break;
			case 5:
				// third byte of 1111 0aaa 10bb bbbb 10cc cccc 10dd dddd
				if ((a & 0xC0) == 0x80) {
					val |= (a & 0x3F);
					state = 6;
				} else {
					chars[pos + (nb++)] = invalidChar;
					state = 0;
				}
				break;
			case 6:
				// fourth byte of 1111 0aaa 10bb bbbb 10cc cccc 10dd dddd
				if ((a & 0xC0) == 0x80) {
					// UTF-8:   [1111 0uuu] [10uu zzzz] [10yy yyyy] [10xx xxxx]*
					// Unicode: [1101 10ww] [wwzz zzyy] (high surrogate)
					//          [1101 11yy] [yyxx xxxx] (low surrogate)
					//          * uuuuu = wwww + 1
					int uuuuu = (val & 0x7C00) >> 10;
					// TODO if > 0x10 invalid Surrogate
					int wwww = uuuuu - 1;
					chars[pos + (nb++)] = (char)(0xD800 | (wwww << 6) | ((val & 0x3C0) >> 4) | ((val & 0x30) >> 4));
					val = (0xDC00 | ((val & 0xF) << 6) | (a & 0x3F));
					state = 7;
				} else {
					chars[pos + (nb++)] = invalidChar;
					state = 0;
				}
				break;
			case 7:
				chars[pos + (nb++)] = (char)val;
				state = 0;
				break;
			}
		}
		return nb;
	}