|
13 | 13 | <v-radio label="Ints (1 7 255)" value="ints"></v-radio>
|
14 | 14 | <v-radio label="Hex (01 07 FF)" value="hex"></v-radio>
|
15 | 15 | <v-radio label="Hex with 0x (0x01 0x07 0xFF)" value="hex0x"></v-radio>
|
| 16 | + <v-radio label="Printf ('\\x01' '\\x07' '\\xFF')" value="printf" title="printf, ignores space and comma selections"></v-radio> |
16 | 17 | </v-radio-group>
|
17 | 18 | <v-checkbox
|
18 | 19 | v-model="byteUpperCase"
|
@@ -164,7 +165,7 @@ export default defineComponent({
|
164 | 165 | // const byteCopyCommas = ref(localStorage.getItem('byteCopyCommas') === 'true');
|
165 | 166 | // const sendAddress = ref(localStorage.getItem('sendAddress') || '');
|
166 | 167 | // const byteUpperCase = ref(localStorage.getItem('byteUpperCase') === 'true');
|
167 |
| - const byteDisplayType = ref<'ints' | 'hex' | 'hex0x'>('ints'); |
| 168 | + const byteDisplayType = ref<'ints' | 'hex' | 'hex0x' | 'printf'>('ints'); |
168 | 169 | const byteCopySpaces = ref(true);
|
169 | 170 | const byteCopyCommas = ref(false);
|
170 | 171 | const sendAddress = ref('');
|
@@ -238,11 +239,15 @@ export default defineComponent({
|
238 | 239 |
|
239 | 240 | const copyToClipboard = () => {
|
240 | 241 | let text = props.byteString.split(' ').map(byte => formatByte(byte)).join(' ');
|
241 |
| - if (byteCopyCommas.value) { |
242 |
| - text = text.replace(/ /g, ', '); |
243 |
| - } |
244 |
| - if (!byteCopySpaces.value) { |
245 |
| - text = text.replace(/ /g, ''); |
| 242 | + if (byteDisplayType.value === 'printf') { |
| 243 | + text = props.byteString.split(' ').map(byte => `'\\x${parseInt(byte).toString(16).padStart(2, '0')}'`).join(''); |
| 244 | + } else { |
| 245 | + if (byteCopyCommas.value) { |
| 246 | + text = text.replace(/ /g, ', '); |
| 247 | + } |
| 248 | + if (!byteCopySpaces.value) { |
| 249 | + text = text.replace(/ /g, ''); |
| 250 | + } |
246 | 251 | }
|
247 | 252 | navigator.clipboard.writeText(text).then(() => {
|
248 | 253 | console.log('Copied to clipboard:', text);
|
|
0 commit comments