Board index » Visual Studio » special characters

special characters

Visual Studio383
Hi,



I'm using ADO 2.6 and VB 6.0. I have to open a text file a asign it to a

recordset. The text file has fileds and its own schema.ini file.



My problem is when I read Spanish characters, such as Ã? it converts it to Ã?

and the ñ to ¦



How can avoid this conversions? it's not the code that its making it, its ADO.



----------------------------------------------------------------------------------------



This is the schema.ini header:



[Myfile.txt]

ColNameHeader = True

Format=TabDelimited

MaxScanRows = 25

CharacterSet=OEM

Col1="Column1" Integer

Col2="Column2" Integer

...etc..





The recordset is opened twice like this:

Set rstConsulta_t = New ADODB.Recordset

rstConsulta_t.Open "SELECT * FROM Myfile.txt", "Driver={Microsoft Text

Driver (*.txt; *.csv)};Initial Catalog=" & strWorkDir_p & ";", adOpenStatic,

adLockBatchOptimistic



If Trim(Dir(strWorkDir_p & "Myfile.dtg", vbArchive)) <>"" Then Kill

strWorkDir_p & "Myfile.dtg"

rstConsulta_t.Save strWorkDir_p & "Myfile.dtg", adPersistADTG

rstConsulta_t.Close

Set rstConsulta_t = Nothing

Kill strWorkDir_p & "Myfile.txt"



Set rstConsulta_t = New ADODB.Recordset

rstConsulta_t.Open strWorkDir_p & "Myfile.dtg",

"Provider=MSPersist", adOpenDynamic, adLockBatchOptimistic, adCmdFile



The objective of opening it twice is to speed up some processes which are

provided with the ADTG file format.





--

Thanks,



Rick.



"For every problem, there is a solution that is simple, neat, and wrong."

H. L. Mencken"


-
 

Re:special characters

On Wed, 8 Aug 2007 05:48:00 -0700, Rick <Rick@discussions.microsoft.com>wrote:



¤ Hi,

¤

¤ I'm using ADO 2.6 and VB 6.0. I have to open a text file a asign it to a

¤ recordset. The text file has fileds and its own schema.ini file.

¤

¤ My problem is when I read Spanish characters, such as Ñ it converts it to Ð

¤ and the ñ to ¦

¤

¤ How can avoid this conversions? it's not the code that its making it, its ADO.

¤

¤ ----------------------------------------------------------------------------------------

¤

¤ This is the schema.ini header:

¤

¤ [Myfile.txt]

¤ ColNameHeader = True

¤ Format=TabDelimited

¤ MaxScanRows = 25

¤ CharacterSet=OEM

¤ Col1="Column1" Integer

¤ Col2="Column2" Integer

¤ ...etc..

¤

¤

¤ The recordset is opened twice like this:

¤ Set rstConsulta_t = New ADODB.Recordset

¤ rstConsulta_t.Open "SELECT * FROM Myfile.txt", "Driver={Microsoft Text

¤ Driver (*.txt; *.csv)};Initial Catalog=" & strWorkDir_p & ";", adOpenStatic,

¤ adLockBatchOptimistic

¤

¤ If Trim(Dir(strWorkDir_p & "Myfile.dtg", vbArchive)) <>"" Then Kill

¤ strWorkDir_p & "Myfile.dtg"

¤ rstConsulta_t.Save strWorkDir_p & "Myfile.dtg", adPersistADTG

¤ rstConsulta_t.Close

¤ Set rstConsulta_t = Nothing

¤ Kill strWorkDir_p & "Myfile.txt"

¤

¤ Set rstConsulta_t = New ADODB.Recordset

¤ rstConsulta_t.Open strWorkDir_p & "Myfile.dtg",

¤ "Provider=MSPersist", adOpenDynamic, adLockBatchOptimistic, adCmdFile

¤

¤ The objective of opening it twice is to speed up some processes which are

¤ provided with the ADTG file format.



I believe that the problem is likely that the Text driver does not support the unicode character

set, only ANSI and OEM (as defined in the schema.ini file).





Paul

~~~~

Microsoft MVP (Visual Basic)

-

Re:special characters

When I set CharacterSet=ANSI on the schema.ini file the ñ is converted to

±, so now I have different caracters.



Is there an Unicode drive for text files?



the VB6 application is running under Windows 2000 sp4 and Windows XP sp2

(and possibly Windows Vista).



--

Thanks,



Rick.



"For every problem, there is a solution that is simple, neat, and wrong."

H. L. Mencken"





"Paul Clement" wrote:



Quote
On Wed, 8 Aug 2007 05:48:00 -0700, Rick <Rick@discussions.microsoft.com>wrote:



¤ Hi,

¤

¤ I'm using ADO 2.6 and VB 6.0. I have to open a text file a asign it to a

¤ recordset. The text file has fileds and its own schema.ini file.

¤

¤ My problem is when I read Spanish characters, such as � it converts it to �

¤ and the ñ to ¦

¤

¤ How can avoid this conversions? it's not the code that its making it, its ADO.

¤

¤ ----------------------------------------------------------------------------------------

¤

¤ This is the schema.ini header:

¤

¤ [Myfile.txt]

¤ ColNameHeader = True

¤ Format=TabDelimited

¤ MaxScanRows = 25

¤ CharacterSet=OEM

¤ Col1="Column1" Integer

¤ Col2="Column2" Integer

¤ ...etc..

¤

¤

¤ The recordset is opened twice like this:

¤ Set rstConsulta_t = New ADODB.Recordset

¤ rstConsulta_t.Open "SELECT * FROM Myfile.txt", "Driver={Microsoft Text

¤ Driver (*.txt; *.csv)};Initial Catalog=" & strWorkDir_p & ";", adOpenStatic,

¤ adLockBatchOptimistic

¤

¤ If Trim(Dir(strWorkDir_p & "Myfile.dtg", vbArchive)) <>"" Then Kill

¤ strWorkDir_p & "Myfile.dtg"

¤ rstConsulta_t.Save strWorkDir_p & "Myfile.dtg", adPersistADTG

¤ rstConsulta_t.Close

¤ Set rstConsulta_t = Nothing

¤ Kill strWorkDir_p & "Myfile.txt"

¤

¤ Set rstConsulta_t = New ADODB.Recordset

¤ rstConsulta_t.Open strWorkDir_p & "Myfile.dtg",

¤ "Provider=MSPersist", adOpenDynamic, adLockBatchOptimistic, adCmdFile

¤

¤ The objective of opening it twice is to speed up some processes which are

¤ provided with the ADTG file format.



I believe that the problem is likely that the Text driver does not support the unicode character

set, only ANSI and OEM (as defined in the schema.ini file).





Paul

~~~~

Microsoft MVP (Visual Basic)



-

Re:special characters

What character set is your text file using Rick? For instance, current ANSI

set, other non-current ANSI set, OEM set, Unicode, UTF-8. If the characters

are visible as you'd expect them when viewing the file in Notepad, look at

the 'Encoding' box in the 'Save As' dialog



Tony Proctor



"Rick" <Rick@discussions.microsoft.com>wrote in message

Quote
When I set CharacterSet=ANSI on the schema.ini file the ñ is converted

to

±, so now I have different caracters.



Is there an Unicode drive for text files?



the VB6 application is running under Windows 2000 sp4 and Windows XP sp2

(and possibly Windows Vista).



--

Thanks,



Rick.



"For every problem, there is a solution that is simple, neat, and wrong."

H. L. Mencken"





"Paul Clement" wrote:



>On Wed, 8 Aug 2007 05:48:00 -0700, Rick <Rick@discussions.microsoft.com>

wrote:

>

>¤ Hi,



>¤ I'm using ADO 2.6 and VB 6.0. I have to open a text file a asign it to

a

>¤ recordset. The text file has fileds and its own schema.ini file.



>¤ My problem is when I read Spanish characters, such as Ñ it converts it

to Ð

>¤ and the ñ to ¦



>¤ How can avoid this conversions? it's not the code that its making it,

its ADO.



>

¤ --------------------------------------------------------------------------

--------------

Quote


>¤ This is the schema.ini header:



>¤ [Myfile.txt]

>¤ ColNameHeader = True

>¤ Format=TabDelimited

>¤ MaxScanRows = 25

>¤ CharacterSet=OEM

>¤ Col1="Column1" Integer

>¤ Col2="Column2" Integer

>¤ ...etc..





>¤ The recordset is opened twice like this:

>¤ Set rstConsulta_t = New ADODB.Recordset

>¤ rstConsulta_t.Open "SELECT * FROM Myfile.txt", "Driver={Microsoft

Text

>¤ Driver (*.txt; *.csv)};Initial Catalog=" & strWorkDir_p & ";",

adOpenStatic,

>¤ adLockBatchOptimistic



>¤ If Trim(Dir(strWorkDir_p & "Myfile.dtg", vbArchive)) <>""

Then Kill

>¤ strWorkDir_p & "Myfile.dtg"

>¤ rstConsulta_t.Save strWorkDir_p & "Myfile.dtg", adPersistADTG

>¤ rstConsulta_t.Close

>¤ Set rstConsulta_t = Nothing

>¤ Kill strWorkDir_p & "Myfile.txt"



>¤ Set rstConsulta_t = New ADODB.Recordset

>¤ rstConsulta_t.Open strWorkDir_p & "Myfile.dtg",

>¤ "Provider=MSPersist", adOpenDynamic, adLockBatchOptimistic, adCmdFile



>¤ The objective of opening it twice is to speed up some processes which

are

>¤ provided with the ADTG file format.

>

>I believe that the problem is likely that the Text driver does not

support the unicode character

>set, only ANSI and OEM (as defined in the schema.ini file).

>

>

>Paul

>~~~~

>Microsoft MVP (Visual Basic)

>





-