Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

strange Dos metacharacters
I have a text file of .srt subtitles downloaded in dos fornat,
and want to convert to unix text style.  I have no problems
removing the ^M character with sed (using ctrl-V ctrl-M).

But every other character in the file is this "^@" :

^@m^@a^@ ^@p^@i^@c^@c^@o^@l^@o^@ ^@t^@a^@g^@l^@i^@o^@.^@^@

I can't seem to produce this control sequence on the keyboard.
Does anyone know what it is?

Cheers,
Simon

--
Spectral Horse Poems
ww.spectralhorse.com
Coins in the Void

Report this thread to moderator Post Follow-up to this message
Old Post
simonp@nospam.com
04-03-08 03:54 AM


Re: strange Dos metacharacters
* simonp@nospam.com <simonp@nospam.com>:
> I have a text file of .srt subtitles downloaded in dos fornat,
> and want to convert to unix text style.  I have no problems
> removing the ^M character with sed (using ctrl-V ctrl-M).
>
> But every other character in the file is this "^@" :
>
> ^@m^@a^@ ^@p^@i^@c^@c^@o^@l^@o^@ ^@t^@a^@g^@l^@i^@o^@.^@^@
>
> I can't seem to produce this control sequence on the keyboard.
> Does anyone know what it is?
>
> Cheers,
> Simon

Looks as if you have a UTF-16 encoded file as opposed to ASCII, Latin1,
or UTF-8.  You'll need something like iconv to convert it.

--
James Michael Fultz <xyzzy@sent.as.invalid>
Remove this part when replying    ^^^^^^^^

Report this thread to moderator Post Follow-up to this message
Old Post
James Michael Fultz
04-03-08 03:54 AM


Re: strange Dos metacharacters
On my slackware xterm bash:

$ for i in $(seq 0 255)
> do printf "$i \x`printf %x $i`\n"
> done|cat -v|grep @
0 ^@
64 @
128 M-^@
192 M-@
$
$ echo -e "\x00"|cat -v
^@
$
$ echo -e "\000"|cat -v
^@
$
$ echo -e "m\000a\rc"|cat -v
m^@a^Mc
$ echo -e "m\000a\rc"|tr -d '\000\r'|cat -v
mac
$



Report this thread to moderator Post Follow-up to this message
Old Post
mop2
04-03-08 03:54 AM


Re: strange Dos metacharacters
James Michael Fultz <xyzzy@sent.as.invalid> wrote:
> * simonp@nospam.com <simonp@nospam.com>: 
>
> Looks as if you have a UTF-16 encoded file as opposed to ASCII, Latin1,
> or UTF-8.  You'll need something like iconv to convert it.
>

Thanks for the tip, that was exactly the problem.

The _file_ utility (which I just discovered) identified it  as
UTF-16, and iconv converted easily to ASCII.

(Turns out the subtitles are in Italian though.)

Cheers,
Simon

--
Spectral Horse Poems
ww.spectralhorse.com
Coins in the Void

Report this thread to moderator Post Follow-up to this message
Old Post
simonp@nospam.com
04-03-08 11:26 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Unix Shell Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 03:22 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.