mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-05 22:07:10 -04:00
fix(integer-basee-converter): handle prefix/suffix and case in sensitive
Handle common languages prefix : 0x, 0o, 0b (C/C#), &H, &O, &B (vb.net) Handle common languages suffix : I (vb.net), U/L (C/C# unsigned and long), n (js bigint) Handle case insensitive for base < 36 (ie, hexa) ( 36 = décimal + lower letters) Fix #694
This commit is contained in:
parent
a07806cd15
commit
e336ebe6bb
3 changed files with 65 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
|||
<script setup lang="ts">
|
||||
import InputCopyable from '../../components/InputCopyable.vue';
|
||||
import { convertBase } from './integer-base-converter.model';
|
||||
import { convertBase, hasNumberPrefix } from './integer-base-converter.model';
|
||||
import { getErrorMessageIfThrows } from '@/utils/error';
|
||||
|
||||
const inputProps = {
|
||||
|
@ -15,6 +15,8 @@ const input = ref('42');
|
|||
const inputBase = ref(10);
|
||||
const outputBase = ref(42);
|
||||
|
||||
const hasInputNumberPrefix = computed(() => hasNumberPrefix(input.value));
|
||||
|
||||
function errorlessConvert(...args: Parameters<typeof convertBase>) {
|
||||
try {
|
||||
return convertBase(...args);
|
||||
|
@ -36,7 +38,7 @@ const error = computed(() =>
|
|||
<c-card>
|
||||
<c-input-text v-model:value="input" label="Input number" placeholder="Put your number here (ex: 42)" label-position="left" label-width="110px" mb-2 label-align="right" />
|
||||
|
||||
<n-form-item label="Input base" label-placement="left" label-width="110" :show-feedback="false">
|
||||
<n-form-item v-if="!hasInputNumberPrefix" label="Input base" label-placement="left" label-width="110" :show-feedback="false">
|
||||
<n-input-number v-model:value="inputBase" max="64" min="2" placeholder="Put your input base here (ex: 10)" w-full />
|
||||
</n-form-item>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue