forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Text/Code recognition

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1751
Location: Space and Time

PostPosted: Sat Sep 01, 2012 6:43 pm    Post subject: Text/Code recognition Reply with quote

Does anyone know (or have example code) of a good way to recognize types of text/code. Take a file/bit of text and be able to tell if it is HTML, PHP, CSS etc..

Thanks!

_________________
Chris
Http://theblindhouse.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sun Sep 23, 2012 1:19 pm    Post subject: Reply with quote

Not VDS code, but may be usefull Smile

http://softwaremaniacs.org/soft/highlight/en/

_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
bornsoft
Contributor
Contributor


Joined: 19 Feb 2009
Posts: 113
Location: Germany

PostPosted: Mon Nov 05, 2012 1:14 pm    Post subject: Reply with quote

I would simply search for certain tags:


Code:


%T = Your text

if @greater(@pos("<?",%T),0)
    info PHP
  elsif @greater(@pos("<br",%T),0)
    info HTML
  elsif @greater(@pos("color:",%T),0)
    info CSS
  else
    info TEXT
end




Of course this is only an example, in real to be sure you need some more testing.

Greetings

bornSoft
.
Back to top
View user's profile Send private message Visit poster's website
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1751
Location: Space and Time

PostPosted: Mon Nov 05, 2012 9:36 pm    Post subject: Reply with quote

Yes, that is what I thought would be best also. I am going to have to put a few different tags to look for in each because some tags might not be used in the code.
_________________
Chris
Http://theblindhouse.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
bornsoft
Contributor
Contributor


Joined: 19 Feb 2009
Posts: 113
Location: Germany

PostPosted: Tue Nov 06, 2012 1:35 am    Post subject: Reply with quote

Hey LiquidCode,

The biggest problem I think is, that in fact all code files are text-files.
A file "RFC_xyz.txt" for example could contain such tags.
Only a combination of different testing methods is a nearly secure way to do it. This is not a problem of VDS, it's a generally problem.

I made a DSU "bsFile" some time ago which has a sub-function "bin" included to test if a file is a binary or a text file, which is pretty reliable. It could help you to test if a file is text at all. It also deals with unicode-files, which I think was the original reason to make this unit.

I never published this DSU here before, don't know why, probably no time. For my needs all works perfectly.

This unit requires VDS6. (Sorry, but I bought VDS6 and so I want to profit by it's benefits. Feel free to port it to VDS5.)

You can download it here including the sourcecode.

http://www.vdsworld.com/forum/download.php?id=374

Greetings. bornSoft

.



Unit_bsFile.zip
 Description:
bsFile.dsu

- read and write variables from/to disk files
- check for binary/text/unicode files
- process unicode files

Download
 Filename:  Unit_bsFile.zip
 Filesize:  7.99 KB
 Downloaded:  1655 Time(s)

Back to top
View user's profile Send private message Visit poster's website
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1751
Location: Space and Time

PostPosted: Tue Nov 06, 2012 6:47 pm    Post subject: Reply with quote

Thank I'll take a look!
_________________
Chris
Http://theblindhouse.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group