Skip to content

Commit

Permalink
fixed #1 v0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
hustcc committed Jan 17, 2017
1 parent 9cbf793 commit 60aa98d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
7 changes: 4 additions & 3 deletions dist/xmorse.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Copyright (c) 2017 hustcc
* License: MIT
* Version: v0.0.1
* Version: v0.0.2
* GitHub: https://github.com/hustcc/xmorse
**/
/* jshint expr: true */
Expand Down Expand Up @@ -106,8 +106,9 @@ function () {

function morseHexUnicode(mor) {
mor = mor.replace(/\./g, '0').replace(/\-/g, '1'); // 转二进制
mor = '%u' + parseInt(mor, 2).toString(16); // 转 16 进制 -> unicode
return unescape(mor); // unicode 转字符串
mor = parseInt(mor, 2); // 解析 2 进制数
if (isNaN(mor)) return ''; // 解析失败,直接返回空字符串跳过
return unescape('%u' + mor.toString(16)); // 转 16 进制 -> unicode -> unicode 转字符串
}

function decode(morse) {
Expand Down
4 changes: 2 additions & 2 deletions dist/xmorse.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "xmorse",
"officialName": "xmorse",
"version": "0.0.1",
"summary": "xmorse is a pure JavaScript library for encoding/decoding morse code messages, unicode supported.",
"description": "xmorse is a pure JavaScript library for encoding/decoding morse code messages, unicode supported.",
"version": "0.0.2",
"summary": "xmorse is a pure javascript(~1.4kb) library for encode / decode morse code messages, unicode supported.",
"description": "xmorse is a pure javascript(~1.4kb) library for encode / decode morse code messages, unicode supported.",
"author": {
"name": "hustcc",
"url": "http://git.hust.cc/xmorse"
Expand All @@ -16,7 +16,8 @@
"morse encode",
"morse decode",
"unicode morse",
"中文morse"
"中文morse",
"中文摩斯密码"
],
"main": "dist/xmorse.min.js",
"repository": {
Expand Down
5 changes: 3 additions & 2 deletions src/xmorse.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ function () {

function morseHexUnicode(mor) {
mor = mor.replace(/\./g, '0').replace(/\-/g, '1'); // 转二进制
mor = '%u' + parseInt(mor, 2).toString(16); // 转 16 进制 -> unicode
return unescape(mor); // unicode 转字符串
mor = parseInt(mor, 2); // 解析 2 进制数
if (isNaN(mor)) return ''; // 解析失败,直接返回空字符串跳过
return unescape('%u' + mor.toString(16)); // 转 16 进制 -> unicode -> unicode 转字符串
}

function decode(morse) {
Expand Down

0 comments on commit 60aa98d

Please sign in to comment.