Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Functions

Functions

decode

  • decode(buffer: any, encoding: string): string
  • Decode the byte buffer that encoding with GBK, GB18030, GB2132, ISO8859_1 .etc to a utf-8 string.

    example
    
    import * as iconv from 'iconv';
    import * as http from 'http';
    import {Encoding} from 'buffer';
    
    let client = http.newClient();
    let resp = client.get('xxx.com/login');
    let iconv.decode(resp.data, Encoding.Utf8);
    

    Parameters

    • buffer: any

      the byte buffer that encoding with GBK, GB18030, GB2132, ISO8859_1 .etc

    • encoding: string

      the encoding method: GBK, GB18030, GB2132, ISO8859_1

    Returns string

encode

  • encode(content: string, encoding: string): any
  • Encode a utf8 string to a buffer that encoding with GBK, GB18030, GB2132, ISO8859_1 .etc

    example
    
    import * as iconv from 'iconv';
    let result = iconv.encode('hello 中国', 'GBK');
    

    Parameters

    • content: string

      the utf8 string

    • encoding: string

      the encoding method: GBK, GB18030, GB2132, ISO8859_1

    Returns any