@@ -8,7 +8,7 @@ const fileName = ref('');
8
8
const fileExtension = ref (' ' );
9
9
const hexInput = ref (' ' );
10
10
const base64Input = computed (() => {
11
- const hexString = hexInput .value ?.replace (/ [^ \d a-f ] / gi , ' ' );
11
+ const hexString = hexInput .value ?.replace (/ ^ (?:0x | &H | \\ x) / gi , ' ' ). replace ( / [^ \d a-f ] / gi , ' ' );
12
12
try {
13
13
return ` data:application/octet-stream;base64,${Buffer .from (hexString , ' hex' ).toString (' base64' )} ` ;
14
14
}
@@ -51,11 +51,13 @@ async function ReadFileAsHex(file: File, separator: string = ' '): Promise<strin
51
51
52
52
const separator = useStorage (' hex-converter:sep' , ' ' );
53
53
const fileInput = ref () as Ref <File >;
54
+ const prefix = useStorage (' hex-converter:prefix' , ' ' );
54
55
const fileHex = computedAsync (async () => {
55
56
const file = fileInput .value ;
56
57
const sep = separator .value ;
58
+ const pref = prefix .value ;
57
59
58
- return await ReadFileAsHex (file , sep );
60
+ return pref + await ReadFileAsHex (file , sep );
59
61
});
60
62
const { copy : copyFileHex } = useCopy ({ source: fileHex , text: ' Hex string copied to the clipboard' });
61
63
@@ -119,6 +121,14 @@ function onUpload(file: File) {
119
121
mb-2
120
122
/>
121
123
124
+ <c-input-text
125
+ v-model:value =" prefix"
126
+ label =" Prefix"
127
+ label-position =" left"
128
+ placeholder =" Enter a prefix (ie, 0x, &H or empty)"
129
+ mb-2
130
+ />
131
+
122
132
<n-divider />
123
133
124
134
<n-form-item label =" File in Hex" >
0 commit comments