blob: 13b6af9e4f8a683f59d41720be13182487202afc [file] [log] [blame]
<?xml version="1.0"?>
<!--
$RCSfile: Writer.ImportingAPlainTextEncodedWithAGivenCharacterSet.snip,v $
last change: $Revision: 1.1 $ $Author: tomsontom $ $Date: 2007/01/04 14:39:35 $
(c)2003 by the copyright holders listed with the author-tags.
If no explicit copyright holder is mentioned with a certain author,
the author him-/herself is the copyright holder. All rights reserved.
Public Documentation License Notice:
The contents of this Documentation are subject to the
Public Documentation License Version 1.0 (the "License");
you may only use this Documentation if you comply with
the terms of this License. A copy of the License is
available at http://www.openoffice.org/licenses/PDL.html
The Original Documentation can be found in the CVS archives
of openoffice.org at the place specified by RCSfile: in this header.
The Initial Writer(s) of the Original Documentation are listed
with the author-tags below.
The Contributor(s) are listed with the author-tags below
without the marker for being an initial author.
All Rights Reserved.
-->
<snippet language="OOBasic" application="Writer">
<keywords>
<keyword>Text (encoded)</keyword>
<keyword>FilterOptions</keyword>
</keywords>
<authors>
<author id="cedricbosdo" initial="true" email="cedric.bosdonnat.ooo@free.fr" copyright="2007 (c) StarXpert">Cedric Bosdonnat</author>
</authors>
<question heading="Importing a plain text encoded with a given character set">How to import a plain text file encoded with a given character set
<p>Simply suppose we need to import MyTest.txt which is encoded in IBM850, also knwon as cp850.</p>
</question>
<answer>
<p>For this, we need to use the &apos;Text (encoded)&apos; filter and configure it properly as shown by the code snippet.</p>
<p>The possible character set codes are all listed on this page: http://equalitylearning.org/~robertz/oo_encoding_indexes.html</p>
<listing> Dim oMediaDescriptor(1) as new {@see com.sun.star.beans.PropertyValue}
sFileUrl = convertToUrl( &quot;H:\My Test.txt&quot; )
oMediaDescriptor(0).name = &quot;FilterName&quot;
oMediaDescriptor(0).value = &quot;Text (encoded)&quot;
oMediaDescriptor(1).name = &quot;FilterOptions&quot;
oMediaDescriptor(1).value = &quot;IBM_850&quot;
oDoc = StarDesktop.loadComponentFromURL(sFileURL, &quot;_blank&quot;, 0, oMediaDescriptor)</listing>
</answer>
<versions>
<version number="2.0.x" status="tested"/>
</versions>
<operating-systems>
<operating-system name="All"/>
</operating-systems>
<changelog>
<change author-id="cedricbosdo" date="2007-01-03">Initial version</change>
</changelog>
</snippet>