• This project
    • Loading...
  • Sign in

fe / yohobuywap-node · Files

Go to a project

GitLab

  • Go to group
  • Project
  • Activity
  • Files
  • Commits
  • Pipelines 0
  • Builds 0
  • Graphs
  • Milestones
  • Issues 0
  • Merge Requests 0
  • Members
  • Labels
  • Wiki
  • Forks
  • Network
  • Create a new issue
  • yohobuywap-node
  • utils
  • string-code.js
  • 'url编码try-catch'
    050fe287
    by 郝肖肖
    2018-01-02 15:48:07 +0800  
    Browse Files
string-code.js 329 Bytes
Raw Blame History Permalink
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
'use strict';

const _ = require('lodash');

const utf8ToHex = (string) => {
    var buf = new Buffer(string, 'utf8');

    return _.toUpper(buf.toString('hex'));
};

const hexToUtf8 = (string) => {
    let buf = new Buffer(string, 'hex');

    return buf.toString('utf8');
};

module.exports = {
    utf8ToHex,
    hexToUtf8
};