Skip to content

Commit

Permalink
Merge pull request #2 from YujiSODE/Y20180517
Browse files Browse the repository at this point in the history
Y20180517
  • Loading branch information
YujiSODE authored May 17, 2018
2 parents 513b107 + 861f30b commit 2b77725
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
# txtMap
Tool for hexadecimal text data mapping.
https://github.com/YujiSODE/txtMap
GitHub: https://github.com/YujiSODE/txtMap
>Copyright (c) 2017 Yuji SODE \<yuji.sode@gmail.com\>
>This software is released under the MIT License.
>See LICENSE or http://opensource.org/licenses/mit-license.php
______
## 1. Synopsis
**Output**
- `::txtMap::outputMap hexTxt W fileName;`
it outputs mapping result
- `::txtMap::outputHexMap hexTxt W fileName;`
it outputs mapping result in hexadecimals
- `::txtMap::outputHexMap cMap fileName;`
it outputs hexadecimal map converted from unicode character map

**Parameters**
Parameters
- `$hexTxt`: utf-8 encoded string that is composed of hexadecimal characters (`0-1` and `a-f`)
and newline character (Unicode `U+00000A`)
- `$cMap`: unicode character map output by `::txtMap::outputMap` or `::txtMap::hexToMap`
- `$W`: the maximum integer length for output string
- `$fileName`: name of output file

**Hexadecimal scale**
- `scale ?L1 ?R1 ?L2 ?R2????;`
it returns hexadecimal scale

Parameters
- `$L1` and `$L2`: optional left characters
- `$R1` and `$R2`: optional right characters

**Script**
- `txtMap.tcl`

Expand Down
31 changes: 17 additions & 14 deletions txtMap.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,25 @@
# - $toChar: an array of hexadecimal elements and unicode characters
# - $toHex: an array of unicode character elements and hexadecimal values
#== Procedures ==
#
#++++++ output ++++++
# - ::txtMap::outputMap hexTxt W fileName;
#it outputs mapping result
#
# - ::txtMap::outputHexMap hexTxt W fileName;
#it outputs mapping result in hexadecimals
#--- Parameters ---
# - $hexTxt: utf-8 encoded string that is composed of hexadecimal characters (0-1 and a-f) and newline character (Unicode U+00000A)
# - $W: the maximum integer length for output string
# - $fileName: name of output file
#
# - ::txtMap::outputHexMap cMap fileName;
#it outputs hexadecimal map converted from unicode character map
# - $cMap: unicode character map output by `::txtMap::outputMap` or `::txtMap::hexToMap`
# - $fileName: name of output file
#
#++++++ Hexadecimal scale ++++++
# - scale ?L1 ?R1 ?L2 ?R2????;
#it returns hexadecimal scale
# - $L1 and $L2: optional left characters
# - $R1 and $R2: optional right characters
#
#++++++++++++++++++++
# - ::txtMap::to4bitHex list ?Min ?Max??;
#it converts nummerical list into a 4-bit hexadecimal string
Expand All @@ -31,11 +40,6 @@
# 0 and 15 are default values
# - to4bit/to4bit.tcl (Yuji SODE,2018): the MIT License; https://gist.github.com/YujiSODE/448704a261f872865f6bfa9344aaabd9
#
# - ::txtMap::scale ?L1 ?R1 ?L2 ?R2????;
#it returns hexadecimal scale
# - $L1 and $L2: optional left characters
# - $R1 and $R2: optional right characters
#
# - ::txtMap::hexToMap hexTxt W;
#it returns unicode character map using given hexadecimal string and width
# - $hexTxt: utf-8 encoded string that is composed of hexadecimal characters (0-1 and a-f) and newline character (Unicode U+00000A)
Expand Down Expand Up @@ -169,14 +173,13 @@ namespace eval ::txtMap {
close $C;unset C;
return $fileName;
};
#it outputs mapping result in hexadecimals
proc outputHexMap {hexTxt W fileName} {
# - $hexTxt: utf-8 encoded string that is composed of hexadecimal characters (0-1 and a-f) and newline character (Unicode U+00000A)
# - $W: the maximum integer length for output string
#it outputs hexadecimal map converted from unicode character map
proc outputHexMap {cMap fileName} {
# - $cMap: unicode character map output by `::txtMap::outputMap` or `::txtMap::hexToMap`
# - $fileName: name of output file
set C [open $fileName w];
fconfigure $C -encoding utf-8;
puts -nonewline $C [::txtMap::mapToHex [::txtMap::hexToMap $hexTxt $W]];
puts -nonewline $C [::txtMap::mapToHex $cMap];
close $C;unset C;
return $fileName;
};
Expand Down

0 comments on commit 2b77725

Please sign in to comment.