AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

HTML 2 ASCII ...

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
BoBo
Guest





PostPosted: Wed Nov 03, 2004 12:37 am    Post subject: HTML 2 ASCII ... Reply with quote

It seems not possible to get ASCII from HTML using AHK's transform command while ASCII to HTML is possible Crying or Very sad

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


Cool
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Wed Nov 03, 2004 6:49 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
BoBo
Guest





PostPosted: Wed Nov 03, 2004 2:36 pm    Post subject: Reply with quote

The mission I've accomplished Smile

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 Question

Code:
ClipBoard = %filename%
URLDownloadToFile, www.barley.com%[color=red]link[/color]%.wav, [color=blue]%ClipBoard%[/color].wav


Cool
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group