2012/08/31 : 記事更新
ウェブ全体を検索し、断片を見つけましたが、実際には何も役に立たなかったので、あなたに頼ります.
環境に関する情報:
プログラミング言語はVBA / Access 2003
データは既存の「.ini」ファイルから読み込まれます
Access データベースにデータを挿入する必要があります
今私の問題に:
ini ファイル内の情報を含む ini ファイルがあります。ファイルは次のようになります。
[product_details]
product_description=my product description
product_name=my product
product_price=11.0
product_sku=myproduct2012
これらの情報は「products.ini」に保存され、メモ帳またはメモ帳++で開くと正しく表示され、アクセスデータベースに挿入でき、これらの情報をフォームに表示できます
しかし今、誰かがこのようなものを持ちたいと思っています:
[product_details]
product_description=мое описание продукта
product_name=мой продукт
product_price=11.0
product_sku=произведение2012
GetINIValue を介してこれらの情報をロードすると、値は判読できないテキストとしてデータベースに保存されます。
編集:メモ帳/メモ帳++でも正しく表示されるため、キリル文字がiniファイルに正しく転送されます
私は実際に多くのことを試しました(GetINIValueのUNICODEバージョンを使用する、Charのコードを取得する、キリル文字かどうかを確認する)何も役に立ちませんでした。
すべきこと: どの言語であっても、この ini エントリから値を取得するには助けが必要です (この場合、英語、ドイツ語、フランス語、ロシア語で十分です)。
誰かが私を助けてくれることを願っています。
編集:私はこのコードの平和でRemouのテストを試しましたが、次のように開いています:
Dim SQL As String
Dim strValue As String
strValue = GetValueOf("product_details","product_description","C:\cyrillic.txt")
SQL = "UPDATE [products] SET [product_description]='" & strValue & "' WHERE [product_id]=23;"
CurrentDb.Execute SQL,dbseechanges
必要な特定の行を読み取るための関数のコードを次に示します。
Public Function GetValueOf(ByVal Section As String, ByVal Entry As String, ByVal File As String)
Dim fs As New FileSystemObject
Dim ts As TextStream
Dim temp As String
Dim response As String
Dim intresponses As String
Dim SectionFoundBegin As Boolean
Dim SectionFoundEnd As Boolean
Dim DoNext As Boolean
Dim Parse() As String
Dim Finished As Boolean
SectionFoundBegin = False
SectionFoundEnd = False
Set ts = fs.OpenTextFile(File, ForReading, , TristateTrue)
response = ""
intresponses = 1
Finished = False
Do
DoNext = False
temp = ts.ReadLine
If (Not Finished) Then
If (temp = "[" & Section & "]") And Not DoNext Then
SectionFoundBegin = True
DoNext = True
End If
If ((InStr(1, temp, "[") > 0) And (SectionFoundBegin)) And Not DoNext Then
SectionFoundEnd = True
DoNext = True
End If
If (SectionFoundBegin And Not SectionFoundEnd) And Not DoNext Then
If (InStr(1, temp, "=") > 0) Then
Parse = Split(temp, "=")
If (Parse(0) = Entry) Then
While (intresponses <= UBound(Parse))
response = response + Parse(intresponses)
intresponses = intresponses + 1
Wend
DoNext = True
Else
DoNext = True
End If
Else
DoNext = True
End If
End If
End If
Loop Until ts.AtEndOfStream
GetValueOf = response
End Function
必要なもの: 次のようなもの:
"UPDATE [products] SET [product_description]='мое описание продукта' WHERE [product_id]=23;"
私が得るもの:
"UPDATE [products] SET [product_description]='??? ???????? ????????' WHERE [product_id]=23;"
更新:さて、私は本当にあなたの助けになります:
次のコードを挿入しました。
Public Function GetUnicodeValueOf(ByVal Section As String, ByVal Entry As String, ByVal File As String)
Dim fs As Object
Dim ts As Object
Set fs = CreateObject("Scripting.FileSystemObject")
Dim temp As String
Dim strResponse As String
Dim intResponses As Integer
Dim SectionFoundBegin As Boolean
Dim SectionFoundEnd As Boolean
Dim DoNext As Boolean
Dim Parse() As String
Dim Finished As Boolean
On Error GoTo Error_GetUnicodeValueOf
SectionFoundBegin = False
SectionFoundEnd = False
Set ts = fs.OpenTextFile(File, ForReading, , TristateTrue)
strResponse = ""
intResponses = 1
Finished = False
Do
DoNext = False
temp = ts.ReadLine
If (Not Finished) Then
If (temp = "[" & Section & "]") And Not DoNext Then
SectionFoundBegin = True
DoNext = True
End If
If ((InStr(1, temp, "[") > 0) And (SectionFoundBegin)) And Not DoNext Then
SectionFoundEnd = True
DoNext = True
End If
If (SectionFoundBegin And Not SectionFoundEnd) And Not DoNext Then
If (InStr(1, temp, "=") > 0) Then
Parse = Split(temp, "=")
If (Parse(0) = Entry) Then
While (intResponses <= UBound(Parse))
strResponse = strResponse + Parse(intResponses)
intResponses = intResponses + 1
Finished = True
Wend
DoNext = True
Else
DoNext = True
End If
Else
DoNext = True
End If
End If
End If
Loop Until ts.AtEndOfStream
Exit_GetUnicodeValueOf:
GetUnicodeValueOf = strResponse
Exit Function
Error_GetUnicodeValueOf:
ActionLogging "Fehler beim Parsen der Datei '" & File & "'"
Resume Exit_GetUnicodeValueOf
End Function
ハードディスクでこのファイル (BOM なしの UTF-8 として保存) を使用して:
[product_details]
manufacturer_name=
product_id=50
sku=BU-01722
set=4
type=simple
type_id=simple
color=11
ean=
name=Колесникова
description=[LANGTEXT] Колесникова Е.В Я считаю до двадцати [Рабочая тетрадь] 6-7л
short_description=[KURZTEXT] Колесникова Е.В
old_id=
weight=1.0000
news_from_date=
news_to_date=
status=1
url_key=kolesnikova
url_path=kolesnikova.html
visibility=4
gift_message_available=2
required_options=0
has_options=0
image_label=
small_image_label=
thumbnail_label=
created_at=2012-06-25 07:58:29
updated_at=2012-07-27 09:06:24
price=2.0000
special_price=
special_from_date=
special_to_date=
cost=
tax_class_id=2
minimal_price=
enable_googlecheckout=1
meta_title=
meta_keyword=
meta_description=
is_recurring=0
recurring_profile=
custom_design=
custom_design_from=
custom_design_to=
custom_layout_update=
page_layout=
options_container=container2
そして私は持っている必要があります:
[LANGTEXT] Колесникова Е.В Я считаю до двадцати [Рабочая тетрадь] 6-7л
INI キーから:説明
私のアクセスデータベースに。
最初は正常に動作しますが、「TriStateTrue」で保存されたファイルをロードすると、すべてが次のようになります:????????????????????????? ???????????????????????? 一行で。
TriStateMixed を使用すると、КолеÑникникова Е.Ð' Я Ñчитаю до двадца のようなキリル文字以外はすべて適切に解析されます。 ти [Ð Ð°Ð±Ð¾Ñ‡Ð°Ñ Ñ‚ÐµÑ‚Ñ€Ð°Ð´ÐŒ] 6-7л
ソースコードを検索しましたが、エラーは見つかりませんでした。
FILE is UTF-8 without BOM (coming from selfwritten Web API for Magento)
Using Access 2003
Need to get Cyrillic Text into my Database where also German / English Texts could be inside the File