| 1 |
/* |
| 2 |
* FeliCa2Money |
| 3 |
* |
| 4 |
* Copyright (C) 2001-2007 Takuya Murakami |
| 5 |
* |
| 6 |
* This program is free software; you can redistribute it and/or modify |
| 7 |
* it under the terms of the GNU General Public License as published by |
| 8 |
* the Free Software Foundation; either version 2 of the License, or |
| 9 |
* (at your option) any later version. |
| 10 |
* |
| 11 |
* This program is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU General Public License |
| 17 |
* along with this program; if not, write to the Free Software |
| 18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 19 |
*/ |
| 20 |
//--------------------------------------------------------------------------- |
| 21 |
|
| 22 |
#include <vcl.h> |
| 23 |
#pragma hdrstop |
| 24 |
#include <stdio.h> |
| 25 |
|
| 26 |
#define DEFINE_TRNNAME |
| 27 |
#include "Transaction.h" |
| 28 |
|
| 29 |
struct trntable trntable_income[] = { |
| 30 |
{"—˜‘§", T_INT}, |
| 31 |
{"�U�ž ", T_DIRECTDEP}, |
| 32 |
{"Á¬°¼Þ", T_DIRECTDEP}, // Edy ƒ`ƒƒ�[ƒW |
| 33 |
{"“ü‹à", T_DIRECTDEP}, // Suica ƒ`ƒƒ�[ƒW |
| 34 |
{NULL, T_DEP} |
| 35 |
}; |
| 36 |
|
| 37 |
struct trntable trntable_outgo[] = { |
| 38 |
{"‚`‚s‚l", T_ATM}, |
| 39 |
{NULL, T_DEBIT} |
| 40 |
}; |
| 41 |
|
| 42 |
/** |
| 43 |
@brief ƒgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“ƒ^ƒCƒv‚ðŽ©“®“I‚É�Ý’è‚·‚é |
| 44 |
@param[in] desc Žæˆø•¶Žš—ñ |
| 45 |
@param[in] type Žæˆøƒ^ƒCƒv(T_INCOME / T_OUTGO) |
| 46 |
|
| 47 |
ƒgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“ƒ^ƒCƒv‚Í type ‚ÉŠi”[‚³‚ê‚é |
| 48 |
*/ |
| 49 |
void Transaction::SetTransactionType(const char *desc, int type) |
| 50 |
{ |
| 51 |
struct trntable *tab; |
| 52 |
|
| 53 |
switch (type) { |
| 54 |
case T_INCOME: |
| 55 |
tab = trntable_income; |
| 56 |
break; |
| 57 |
|
| 58 |
case T_OUTGO: |
| 59 |
tab = trntable_outgo; |
| 60 |
break; |
| 61 |
|
| 62 |
default: |
| 63 |
/* ### */ |
| 64 |
break; |
| 65 |
} |
| 66 |
|
| 67 |
while (tab->key) { |
| 68 |
if (strstr(desc, tab->key) != 0) { |
| 69 |
this->type = tab->type; |
| 70 |
return; |
| 71 |
} |
| 72 |
tab++; |
| 73 |
} |
| 74 |
this->type = tab->type; |
| 75 |
return; |
| 76 |
} |
| 77 |
|
| 78 |
/** |
| 79 |
@brief ƒgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“ƒ^ƒCƒv•¶Žš—ñ‚ðŽæ“¾‚·‚é |
| 80 |
@return ƒgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“ƒ^ƒCƒv•¶Žš—ñ |
| 81 |
*/ |
| 82 |
const char *Transaction::GetTrnTypeStr(void) |
| 83 |
{ |
| 84 |
return trnname[type]; |
| 85 |
} |
| 86 |
|
| 87 |
// |
| 88 |
// ƒ†�[ƒeƒBƒŠƒeƒBŠÖ�” |
| 89 |
// |
| 90 |
|
| 91 |
/** |
| 92 |
@brief SJIS->UTF8•ÏŠ· |
| 93 |
*/ |
| 94 |
AnsiString sjis2utf8(const AnsiString & sjis) |
| 95 |
{ |
| 96 |
wchar_t wbuf[1500]; |
| 97 |
char buf[3000]; |
| 98 |
AnsiString utf8; |
| 99 |
|
| 100 |
MultiByteToWideChar(932/*CP_932, Shift-JIS*/, 0, sjis.c_str(), -1, |
| 101 |
wbuf, sizeof(buf) / 2); |
| 102 |
WideCharToMultiByte(CP_UTF8, 0, wbuf, -1, |
| 103 |
buf, sizeof(buf), NULL, NULL); |
| 104 |
|
| 105 |
utf8 = buf; |
| 106 |
return utf8; |
| 107 |
} |
| 108 |
|
| 109 |
|