#193038 - 2009-03-20 02:56 PM
DOS to ANSI
|
WagnerJu
Fresh Scripter
Registered: 2009-03-20
Posts: 6
Loc: Germany
|
Hi folks, I have a complicated question....
I use some shell-output which gives me characters in german umlaut (äüöß) I redirect this output to a file which I read line per line in my kix-script. After some string operations I output these lines on the console. The console output is redirected to a file because I need to add some more shell output to this file. The resulting file is a csv-file which I want to import in Excel for further formatting.
What happens is this: The shell outputs a string which contains umlaut kix reads this output and writes the lines into a file but the umlaut in this file is still the same character, that the shell has created. Excel does not work with these characters. It seems that the shell output and kix use ASCII-codes and Excel expects ANSI-codes. When I import the csv-fiels with the option MS-DOS Mode, my characters are imported correctly. But by default, Excel expects ANSI-Code.
Shell-output: Jürgen
csv-file: Jürgen
Excel-import: J"rgen
So what I need: when I write a line into my csv-file I need to convert the MS-DOS string to ANSI, replecing all umlaut from MS-DOS format to ANSI format
Any hints?
kind regards
Jürgen
|
Top
|
|
|
|
#193046 - 2009-03-20 05:05 PM
Re: DOS to ANSI
[Re: Lonkero]
|
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11623
Loc: CA
|
It imports just fine for me in Excel. You can choose what character set to use for the conversion in Excel.
|
Top
|
|
|
|
#193117 - 2009-03-24 02:13 PM
Re: DOS to ANSI
[Re: NTDOC]
|
WagnerJu
Fresh Scripter
Registered: 2009-03-20
Posts: 6
Loc: Germany
|
It imports just fine for me in Excel. You can choose what character set to use for the conversion in Excel.
Yes, when I import in Excel, I can tell Excel to use MS-DOS (PC-8) Format. But when I just open the CSV-file, Excel opens with this file without asking for proper codepage.
I just wrote a small function, that converts umlaut from PC-8 to ANSI. and this way it works. But I hoped, to find an easier way.
Function convert($input)
$output=$input
do
$pos=instr($output,"á")
if $pos>0
$output=left($output,$pos-1)+"ß"+substr($output,$pos+1)
endif
until $pos=0
do
$pos=instr($output,"")
if $pos>0
$output=left($output,$pos-1)+"ü"+substr($output,$pos+1)
endif
until $pos=0
do
$pos=instr($output,"„")
if $pos>0
$output=left($output,$pos-1)+"ä"+substr($output,$pos+1)
endif
until $pos=0
do
$pos=instr($output,"”")
if $pos>0
$output=left($output,$pos-1)+"ö"+substr($output,$pos+1)
endif
until $pos=0
do
$pos=instr($output,"™")
if $pos>0
$output=left($output,$pos-1)+"Ö"+substr($output,$pos+1)
endif
until $pos=0
do
$pos=instr($output,"Ž")
if $pos>0
$output=left($output,$pos-1)+"Ä"+substr($output,$pos+1)
endif
until $pos=0
do
$pos=instr($output,"š")
if $pos>0
$output=left($output,$pos-1)+"Ü"+substr($output,$pos+1)
endif
until $pos=0
$convert=$output
EndFunction
thanks for helping
Jürgen
|
Top
|
|
|
|
#193148 - 2009-03-25 10:32 AM
Re: DOS to ANSI
[Re: Lonkero]
|
Lonkero
KiX Master Guru
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
btw, Jürgen... could you modify your convert a bit. I wanna see what asc() codes you get with these failing characters. so, for example try this:
code removed, see next post
that is, add asc(substr(str,instr())) for these characters to the output to see, what the codes are, so you/I/we can determine, what character set is actually used in the original input.
It indeed looks weird that basic character of space is actually "ü"... doesn't make any sense. I thought the base characters are always the same. anyway, once you provide the charcodes, we will see what really is happening here.
Edited by Lonkero (2009-03-25 10:37 AM)
_________________________
!download KiXnet
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 248 anonymous users online.
|
|
|