/**
 * substring.js
 *
 * @Author: wangyinan
 */

export default function subString(str, limit, suffix) {
    var tmp = str.replace(/([^\x00-\xff])/g, '$1 ');
    if (tmp.length > limit && suffix) {
        tmp = tmp.substr(0, limit - 2) + suffix;
    } else if (tmp.length > limit) {
        tmp = tmp.substr(0, limit - 2);
    }
    return tmp.replace(/([^\x00-\xff])\s/g, '$1');
}