AutoHotkey Community

It is currently May 27th, 2012, 8:59 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: HTML 2 ASCII ...
PostPosted: November 3rd, 2004, 12:37 am 
It seems not possible to get ASCII from HTML using AHK's transform command while ASCII to HTML is possible :cry:

Therefore I had a try with a workaround.
Feel free to tweak it :wink:

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


8)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 3rd, 2004, 6:49 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 3rd, 2004, 2:36 pm 
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 :?:

Code:
ClipBoard = %filename%
URLDownloadToFile, www.barley.com%link%.wav, %ClipBoard%.wav


8)


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], specter333 and 9 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group