Skip to content

Commit

Permalink
全角英数記号を半角に変換するように変更
Browse files Browse the repository at this point in the history
”は“と対で使われることが多いので全角のまま保持。
一番根本のTS解析部分での変換なので、元が全角であったという情報は失われる。
録画ファイル名は駄目文字のチェックが入っているので、多分問題ない。(未検証)
受信した文字を全て変換しているので、チャンネルスキャンからやりなせばサービス名も半角になります。
  • Loading branch information
niisaka committed Jun 27, 2013
1 parent 58d72b8 commit f2c394d
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 1 deletion.
27 changes: 27 additions & 0 deletions Common/StringUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,3 +450,30 @@ void EscapeXmlString(wstring& src)
Replace(src, L"\"", L""");
Replace(src, L"'", L"'");
}

void ZtoH(wstring &src)
{
const static wstring from(L" !#$%&’()*+,-./:;<=>?@[¥]^_‘{|}");
const static wstring to(L" !#$%&'()*+,-./:;<=>?@[\\]^_`{|}");

for(wstring::iterator it = src.begin(); it != src.end(); it++)
{
if (*it >= L'' && *it <= L'')
{
*it -= (L'' - L'0');
}
else if (*it >= L'' && *it <= L'')
{
*it -= (L'' - L'a');
}
else if (*it >= L'' && *it <= L'')
{
*it -= (L'' - L'A');
}
else
{
int i = from.find(*it);
if (i != wstring::npos) *it = to[i];
}
}
}
2 changes: 2 additions & 0 deletions Common/StringUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@ wstring Tolower(wstring src);

void EscapeXmlString(wstring& src);

void ZtoH(wstring &src);

#endif
6 changes: 6 additions & 0 deletions EpgDataCap3/EpgDataCap3/DecodeUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,7 @@ DWORD CDecodeUtil::GetServiceListActual(
string network_name = "";
arib.PSISI((const BYTE*)networkName->char_name, networkName->char_nameLength, &network_name);
AtoW(network_name, network_nameW);
ZtoH(network_nameW);
}
}
}
Expand All @@ -884,6 +885,7 @@ DWORD CDecodeUtil::GetServiceListActual(
string ts_name = "";
arib.PSISI((const BYTE*)TSInfo->ts_name_char, TSInfo->length_of_ts_name, &ts_name);
AtoW(ts_name, ts_nameW);
ZtoH(ts_nameW);
}
remote_control_key_id = TSInfo->remote_control_key_id;
}
Expand Down Expand Up @@ -917,7 +919,9 @@ DWORD CDecodeUtil::GetServiceListActual(
wstring service_provider_nameW = L"";
wstring service_nameW = L"";
AtoW(service_provider_name, service_provider_nameW);
ZtoH(service_provider_nameW);
AtoW(service_name, service_nameW);
ZtoH(service_nameW);

this->serviceList[count].extInfo->service_type = service->service_type;
if( service_provider_nameW.size() > 0 ){
Expand Down Expand Up @@ -1018,7 +1022,9 @@ DWORD CDecodeUtil::GetServiceListSIT(
wstring service_provider_nameW = L"";
wstring service_nameW = L"";
AtoW(service_provider_name, service_provider_nameW);
ZtoH(service_provider_nameW);
AtoW(service_name, service_nameW);
ZtoH(service_nameW);

this->serviceList[i].extInfo->service_type = service->service_type;
if( service_provider_nameW.size() > 0 ){
Expand Down
18 changes: 18 additions & 0 deletions EpgDataCap3/EpgDataCap3/EpgDBUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,9 @@ BOOL CEpgDBUtil::AddShortEvent(CEITTable* eit, EVENT_INFO* eventInfo, CShortEven
arib.PSISI((const BYTE*)shortEvent->text_char, shortEvent->text_length, &text_char);

AtoW(event_name, eventInfo->shortInfo->event_name);
ZtoH(eventInfo->shortInfo->event_name);
AtoW(text_char, eventInfo->shortInfo->text_char);
ZtoH(eventInfo->shortInfo->text_char);
}

return updateFlag;
Expand All @@ -615,7 +617,9 @@ BOOL CEpgDBUtil::AddShortEvent_SD(CEITTable_SD* eit, EVENT_INFO* eventInfo, CSho
arib.PSISI((const BYTE*)shortEvent->text_char, shortEvent->text_length, &text_char);

AtoW(event_name, eventInfo->shortInfo->event_name);
ZtoH(eventInfo->shortInfo->event_name);
AtoW(text_char, eventInfo->shortInfo->text_char);
ZtoH(eventInfo->shortInfo->text_char);
}

return updateFlag;
Expand Down Expand Up @@ -730,6 +734,7 @@ BOOL CEpgDBUtil::AddExtEvent(CEITTable* eit, EVENT_INFO* eventInfo, vector<DESCR
//}

AtoW(extendText, eventInfo->extInfo->text_char);
ZtoH(eventInfo->extInfo->text_char);
}

return updateFlag;
Expand Down Expand Up @@ -844,6 +849,7 @@ BOOL CEpgDBUtil::AddExtEvent_SD(CEITTable_SD* eit, EVENT_INFO* eventInfo, vector
//}

AtoW(extendText, eventInfo->extInfo->text_char);
ZtoH(eventInfo->extInfo->text_char);
}

return updateFlag;
Expand Down Expand Up @@ -913,6 +919,7 @@ BOOL CEpgDBUtil::AddComponent(CEITTable* eit, EVENT_INFO* eventInfo, CComponentD
arib.PSISI((const BYTE*)component->text_char, component->text_charLength, &text_char);

AtoW(text_char, eventInfo->componentInfo->text_char);
ZtoH(eventInfo->componentInfo->text_char);
}

}
Expand Down Expand Up @@ -944,6 +951,7 @@ BOOL CEpgDBUtil::AddComponent_SD(CEITTable_SD* eit, EVENT_INFO* eventInfo, CComp
arib.PSISI((const BYTE*)component->text_char, component->text_charLength, &text_char);

AtoW(text_char, eventInfo->componentInfo->text_char);
ZtoH(eventInfo->componentInfo->text_char);
}

}
Expand Down Expand Up @@ -989,6 +997,7 @@ BOOL CEpgDBUtil::AddAudioComponent(CEITTable* eit, EVENT_INFO* eventInfo, vector
arib.PSISI((const BYTE*)audioComponent->text_char, audioComponent->text_charLength, &text_char);

AtoW(text_char, item.text_char);
ZtoH(item.text_char);
}

eventInfo->audioInfo->componentList.push_back(item);
Expand Down Expand Up @@ -1038,6 +1047,7 @@ BOOL CEpgDBUtil::AddAudioComponent_SD(CEITTable_SD* eit, EVENT_INFO* eventInfo,
arib.PSISI((const BYTE*)audioComponent->text_char, audioComponent->text_charLength, &text_char);

AtoW(text_char, item.text_char);
ZtoH(item.text_char);
}

eventInfo->audioInfo->componentList.push_back(item);
Expand Down Expand Up @@ -1352,6 +1362,7 @@ BOOL CEpgDBUtil::AddServiceList(CNITTable* nit)
string network_name = "";
arib.PSISI((const BYTE*)networkName->char_name, networkName->char_nameLength, &network_name);
AtoW(network_name, network_nameW);
ZtoH(network_nameW);
}
}
}
Expand Down Expand Up @@ -1386,6 +1397,7 @@ BOOL CEpgDBUtil::AddServiceList(CNITTable* nit)
string ts_name = "";
arib.PSISI((const BYTE*)desc->TSInfo->ts_name_char, desc->TSInfo->length_of_ts_name, &ts_name);
AtoW(ts_name, itrFind->second->ts_name);
ZtoH(itrFind->second->ts_name);
}
itrFind->second->remote_control_key_id = desc->TSInfo->remote_control_key_id;
}
Expand Down Expand Up @@ -1448,7 +1460,9 @@ BOOL CEpgDBUtil::AddServiceList(WORD TSID, CSITTable* sit)
arib.PSISI((const BYTE*)service->char_service_name, service->service_name_length, &service_name);
}
AtoW(service_provider_name, item->service_provider_name);
ZtoH(item->service_provider_name);
AtoW(service_name, item->service_name);
ZtoH(item->service_name);

item->service_type = service->service_type;
}
Expand Down Expand Up @@ -1494,7 +1508,9 @@ BOOL CEpgDBUtil::AddSDT(CSDTTable* sdt)
arib.PSISI((const BYTE*)service->char_service_name, service->service_name_length, &service_name);
}
AtoW(service_provider_name, item->service_provider_name);
ZtoH(item->service_provider_name);
AtoW(service_name, item->service_name);
ZtoH(item->service_name);

item->service_type = service->service_type;
}
Expand Down Expand Up @@ -1525,7 +1541,9 @@ BOOL CEpgDBUtil::AddSDT(CSDTTable* sdt)
arib.PSISI((const BYTE*)service->char_service_name, service->service_name_length, &service_name);
}
AtoW(service_provider_name, item->service_provider_name);
ZtoH(item->service_provider_name);
AtoW(service_name, item->service_name);
ZtoH(item->service_name);

item->service_type = service->service_type;
}
Expand Down
2 changes: 1 addition & 1 deletion EpgDataCap3/EpgDataCap3/EpgDataCap3.vcxproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerCommand>..\..\x86\Debug\EpgTimerSrv.exe</LocalDebuggerCommand>
<LocalDebuggerWorkingDirectory>..\..\x86\Debug</LocalDebuggerWorkingDirectory>
<LocalDebuggerWorkingDirectory>$(SolutionDir)..\x86\$(Configuration)\</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>

0 comments on commit f2c394d

Please sign in to comment.