Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 全角英数を半角英数に置き換える #6

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/lib/string.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** 全角英数を半角英数に置き換える */
export const replaceFullWidthWithHalfWidth = (str: string) => {
return str.replace(/[A-Za-z0-9]/g, (s) =>
String.fromCharCode(s.charCodeAt(0) - 0xFEE0)
)
}
5 changes: 3 additions & 2 deletions src/store/data.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineStore } from 'pinia'
import { computed, ref } from 'vue'
import { Transaction, TransactionCategory } from '../types/transaction'
import { replaceFullWidthWithHalfWidth } from '../lib/string'

/** 仕訳に応じて収支のセルの値を選択し返す
*
Expand Down Expand Up @@ -116,12 +117,12 @@ export const useDataStore = defineStore('data', () => {
row[header.indexOf('支出')],
),
),
receipt: row[header.indexOf('領収書No')],
receipt: replaceFullWidthWithHalfWidth(row[header.indexOf('領収書No')]),
recipient: row[header.indexOf('謝礼相手先')],
transportPurpose: row[header.indexOf('通信運搬用途')],
printPurpose: row[header.indexOf('印刷目的')],
owner: row[header.indexOf('用具所有者')],
numStay: row[header.indexOf('延べ宿泊数')],
numStay: replaceFullWidthWithHalfWidth(row[header.indexOf('延べ宿泊数')]),
}

result.push(transaction)
Expand Down
Loading