<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; VBS: Перекодировка из Unicode в win1251]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=6610&amp;type=atom" />
	<updated>2011-12-28T07:49:31Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=6610</id>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Перекодировка из Unicode в win1251]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=55067#p55067" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>alexii пишет:</cite><blockquote><p><strong>2BeS Yara</strong>: образец файла *.udl был создан <a href="http://forum.script-coding.com/viewtopic.php?pid=55053#p55053">по методу</a> <strong>Mat Skywalker</strong>&#039;а, и был он в кодировке UTF-16 (1200).</p></blockquote></div><p>Да, уже понял в чём ошибка, ступил. Делал UTF-8, а нужен был UTF-16LE. <br />Для ADO-варианта достаточно поменять кодировку чтения на &quot;Unicode&quot;(или закоментарить строку - юникод дефолтом используется), и убрать конвертирование кодировки(не пойму пока почему при переводе в 1251 остаётся только BOM и левая квадратная скобка).</p>]]></content>
			<author>
				<name><![CDATA[BeS Yara]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25643</uri>
			</author>
			<updated>2011-12-28T07:49:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=55067#p55067</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Перекодировка из Unicode в win1251]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=55063#p55063" />
			<content type="html"><![CDATA[<p><strong>2BeS Yara</strong>: образец файла *.udl был создан <a href="http://forum.script-coding.com/viewtopic.php?pid=55053#p55053">по методу</a> <strong>Mat Skywalker</strong>&#039;а, и был он в кодировке UTF-16 (1200).</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2011-12-28T07:04:20Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=55063#p55063</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Перекодировка из Unicode в win1251]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=55061#p55061" />
			<content type="html"><![CDATA[<p>Это сработало. Спасибо.</p>]]></content>
			<author>
				<name><![CDATA[Mat Skywalker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26275</uri>
			</author>
			<updated>2011-12-28T06:46:24Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=55061#p55061</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Перекодировка из Unicode в win1251]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=55060#p55060" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>alexii пишет:</cite><blockquote><p>With .OpenTextFile</p></blockquote></div><p>У меня такой вариант не отрабатывает:<br /></p><div class="quotebox"><blockquote><p>D:\aScripts\vbs\tmp\udl_fso2.vbs(12, 9) Ошибка выполнения Microsoft VBScript: Ввод данных за пределами файла</p></blockquote></div><p>12-ая строка это второй скип-лайн.<br />Читает из файла только одну строку, хотя при создании udl делал UTF-8 с переносом строк CR+LF(другие варианты юникода и переносов не проверял).<br />ADO-шный вариант с UTF-8 работает, правда BOM в первой строке глаза мозолит.</p>]]></content>
			<author>
				<name><![CDATA[BeS Yara]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25643</uri>
			</author>
			<updated>2011-12-28T06:42:12Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=55060#p55060</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Перекодировка из Unicode в win1251]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=55058#p55058" />
			<content type="html"><![CDATA[<p>Вариант с &quot;ADODB.Stream&quot;:<br /></p><div class="codebox"><pre><code>option explicit
Dim ADODBStream, Text
Set ADODBStream = CreateObject(&quot;ADODB.Stream&quot;)
ADODBStream.Type = 2
ADODBStream.Charset = &quot;UTF-8&quot;
ADODBStream.Open()
ADODBStream.LoadFromFile(&quot;test.udl&quot;)
ADODBStream.Charset = &quot;Windows-1251&quot;
Text = ADODBStream.ReadText()
ADODBStream.Close()
Dim f_regEx, f_Match, f_Matches
Set f_regEx = New RegExp
f_regEx.IgnoreCase = True
f_regEx.Global = True
f_regEx.Multiline = True
f_regEx.Pattern = &quot;^Provider[\w\W]+&quot;
If f_regEx.Test(Text) then
    Set f_Matches = f_regEx.Execute(Text)
    For Each f_Match in f_Matches
      wscript.echo &quot;Connection string: &quot; &amp; f_Match
    Next
  Else
    wscript.echo &quot;Connection string not found&quot;
End If</code></pre></div>]]></content>
			<author>
				<name><![CDATA[BeS Yara]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25643</uri>
			</author>
			<updated>2011-12-28T06:32:49Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=55058#p55058</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Перекодировка из Unicode в win1251]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=55054#p55054" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>Option Explicit

Const ForReading   = 1
Const TristateTrue = -1


With WScript.CreateObject(&quot;Scripting.FileSystemObject&quot;)
    With .OpenTextFile(&quot;E:\Песочница\0101\Some.udl&quot;, ForReading, False, TristateTrue)
        .SkipLine
        .SkipLine
        
        WScript.Echo .ReadLine()
    End With
End With

WScript.Quit 0</code></pre></div><div class="quotebox"><blockquote><div class="codebox"><pre><code>Provider=MSDASQL.1;Persist Security Info=False</code></pre></div></blockquote></div>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2011-12-28T06:13:13Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=55054#p55054</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Перекодировка из Unicode в win1251]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=55053#p55053" />
			<content type="html"><![CDATA[<p>Создайте пустой текстовый файл, переименуйте его в UDL , запустите двойным кликом. Увидите свойства подключения к данным.<br />Если этот файл потом открыть блокнотом увидим примерно это:</p><div class="codebox"><pre><code>[oledb]
; Everything after this line is an OLE DB initstring
Provider=MSDASQL.1;Password=masterkey;Persist Security Info=True;User ID=sysdba;Data Source=Smarket</code></pre></div><p>Т.е. третья строчка - это connection string</p>]]></content>
			<author>
				<name><![CDATA[Mat Skywalker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26275</uri>
			</author>
			<updated>2011-12-28T05:42:29Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=55053#p55053</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Перекодировка из Unicode в win1251]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=55048#p55048" />
			<content type="html"><![CDATA[<p>У OpenTextFile есть ещё два параметра. Четвёртый указывает кодировку в которой будет открыт файл. По умолчанию обычно 1251.<br />Хотя на пустоту это влиять не должно. А сколько в файле строк?</p><p>Не понятно что именно не заработало через ADODBStream. Желательно увидеть сам код.</p><p>Если udl файл не содержит секретов, то я бы не отказался на него взглянуть.</p>]]></content>
			<author>
				<name><![CDATA[BeS Yara]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25643</uri>
			</author>
			<updated>2011-12-28T04:36:26Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=55048#p55048</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[VBS: Перекодировка из Unicode в win1251]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=55046#p55046" />
			<content type="html"><![CDATA[<p>Прошу прощения за &quot;некропостинг&quot;, но вдоволь поискав, не нашел способа чтения *.udl файлов.</p><div class="codebox"><pre><code>
...
        strFilePath = Path+&quot;sm.udl&quot;
		Set objTS = objFS.OpenTextFile(strFilePath, 1)
		objTS.SkipLine
		objTS.SkipLine
		Udlread=objTS.Readline
...</code></pre></div><p>В переменной пустота, потому что текст в файле *.udl хранится в формате Unicode.<br />Перепробовал несколько способов, перекодировать не получилось.<br />Здесь <a href="http://forum.script-coding.com/viewtopic.php?id=997">http://forum.script-coding.com/viewtopic.php?id=997</a> не зароботало тоже.<br />Подскажите, как прочесть UDL ?</p>]]></content>
			<author>
				<name><![CDATA[Mat Skywalker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26275</uri>
			</author>
			<updated>2011-12-28T03:17:56Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=55046#p55046</id>
		</entry>
</feed>
