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加载这些信息时,Value将作为不可读的文本保存到数据库中。
编辑:同样在记事本/记事本++中显示正确,因此西里尔字母正确传输到ini文件中
我真的尝试过很多东西(使用UNICODE版本的GetINIValue,获取Code of 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
在我的Harddisc上使用此文件(保存为无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-Key的:说明
进入我的访问数据库。
首先它应该正常工作,但现在当我加载一个用“TriStateTrue”保存的文件时 一切都归结为:everything everything everything:::::???????? 在一行。
使用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