Visitar URL original
第 124 期(W3C 标准-JavaScript):unicode码互转 · Issue #127 · fezaoduke/fe-practice-hard · GitHub
Skip to content

第 124 期(W3C 标准-JavaScript):unicode码互转 #127

Description

@wingmeng
// 普通字符串转 unicode
// -> "\u4f60\u597d\u4e16\u754c"
'你好世界'.split('').map(s => '\\u' + s.charCodeAt().toString(16)).join('');

// unicode 转普通字符串
String('\u4f60\u597d\u4e16\u754c');  // "你好世界"

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions