Skip to content

Commit 3bad3ad

Browse files
committed
ADDS converter logic
1 parent 7fdacc9 commit 3bad3ad

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

references/ASCII-table.pdf

178 KB
Binary file not shown.

tools/hex-converter/hex_converter/Main.qml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ Window {
8383
elide: Text.ElideRight
8484
}
8585

86+
onClicked: {
87+
input_chars_field.text = ""
88+
}
89+
8690
background: Rectangle {
8791
implicitWidth: 100
8892
implicitHeight: 40
@@ -102,6 +106,33 @@ Window {
102106
font.family: "ubuntu"
103107
font.pixelSize: 23
104108

109+
onClicked: {
110+
console.log(input_chars_field.text)
111+
112+
let input_str = input_chars_field.text
113+
let str_len = input_str.length
114+
let output_str = ""
115+
116+
for(let i=0; i < str_len; i++) {
117+
let ch = input_str[i]
118+
if(ch !== 'string' || ch !== 1) {
119+
console.log("Input must be a single character or string")
120+
}
121+
122+
let unicode_value = ch.charCodeAt(0)
123+
let hex_string = unicode_value.toString(16)
124+
125+
/* append to output string */
126+
output_str += hex_string
127+
}
128+
129+
console.log("HEX OUT: " + output_str)
130+
131+
/* display the text */
132+
output_chars_field.text = output_str
133+
134+
}
135+
105136
contentItem: Text {
106137
text: convert_button.text
107138
font: convert_button.font

0 commit comments

Comments
 (0)