 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
BoBo Guest
|
Posted: Wed Nov 03, 2004 12:37 am Post subject: HTML 2 ASCII ... |
|
|
It seems not possible to get ASCII from HTML using AHK's transform command while ASCII to HTML is possible
Therefore I had a try with a workaround.
Feel free to tweak it
| Code: | #SingleInstance
SetBatchLines, -1
Loop, Read, My.html, MyConverted.txt
{
Line = %A_LoopReadLine%
If Line = ; Skip empty line
Continue
Loop
{
IfInString, Line, &# ; Section to convert identified HTML chars
{
StringGetPos, Pos, Line, &# ; Get position of the HTML char
Pos += 3
StringMid, Val, Line, %Pos%, 4
StringGetPos, ValLen, Val, `;
StringMid, Val, Val, 1, %ValLen% ; Extract its value
Transform, ASCII, Chr, %Val% ; Convert/transform its value to an ASCII char
StringReplace, Line, Line, &#%Val%`;, %ASCII% ; Replace the HTML char with its ASCII char
}
Else
{
Break ; Nothing to convert/transform, keep original line
}
}
FileAppend, %Line%`n ; Write the converted line to the outputfile
}
ExitApp |
 |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Wed Nov 03, 2004 6:49 am Post subject: |
|
|
Nice script. By the way, the transform command doesn't go in the opposite direction because converting from HTML to text (reliably) would probably involve a lot of code unless there's some function built into the OS for that. This is due to all the various tags and syntax that might be present.
However, if you copy HTML onto the clipboard -- such as by copying and pasting from an open browser window -- it will be automatically converted to plain text when you refer to the clipboard variable. |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Wed Nov 03, 2004 2:36 pm Post subject: |
|
|
The mission I've accomplished
I took a line from a file
| Quote: | | /61/46/A0194600,Alfvén, Hannes Olof Gösta |
Downloaded the file from its destination (link) and named it using the kept filename
http://www.barley.com/61/46/A0194600.wav -> Alfvén, Hannes Olof Gösta.wav
Following your advise that'll work to convert (é=ASCII 233 and ö= ASCII 246) as well
 |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|