Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
caa38ffd
Commit
caa38ffd
authored
Oct 07, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tx data decode to utf-8
parent
b5e35553
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
2 deletions
+18
-2
hexToBytes.ts
lib/hexToBytes.ts
+7
-0
hexToUtf8.ts
lib/hexToUtf8.ts
+8
-0
RawInputData.tsx
ui/shared/RawInputData.tsx
+3
-2
No files found.
lib/hexToBytes.ts
0 → 100644
View file @
caa38ffd
export
default
function
hexToBytes
(
hex
:
string
)
{
const
bytes
=
[];
for
(
let
c
=
0
;
c
<
hex
.
length
;
c
+=
2
)
{
bytes
.
push
(
parseInt
(
hex
.
substring
(
c
,
c
+
2
),
16
));
}
return
bytes
;
}
lib/hexToUtf8.ts
0 → 100644
View file @
caa38ffd
import
hexToBytes
from
'
lib/hexToBytes
'
;
export
default
function
hexToUtf8
(
hex
:
string
)
{
const
utf8decoder
=
new
TextDecoder
();
const
bytes
=
new
Uint8Array
(
hexToBytes
(
hex
));
return
utf8decoder
.
decode
(
bytes
);
}
ui/shared/RawInputData.tsx
View file @
caa38ffd
import
{
Box
,
Flex
,
Select
,
Textarea
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
hexToUtf8
from
'
lib/hexToUtf8
'
;
import
CopyToClipboard
from
'
ui/shared/CopyToClipboard
'
;
type
DataType
=
'
Hex
'
|
'
UTF-8
'
...
...
@@ -26,7 +27,7 @@ const RawInputData = ({ hex }: Props) => {
<
CopyToClipboard
text=
{
hex
}
/>
</
Flex
>
<
Textarea
value=
{
selectedDataType
===
'
Hex
'
?
hex
:
'
UTF-8 equivalent
'
}
value=
{
selectedDataType
===
'
Hex
'
?
hex
:
hexToUtf8
(
hex
)
}
w=
"100%"
maxH=
"220px"
mt=
{
2
}
...
...
@@ -38,4 +39,4 @@ const RawInputData = ({ hex }: Props) => {
);
};
export
default
R
awInputData
;
export
default
R
eact
.
memo
(
RawInputData
)
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment