View previous topic :: View next topic |
Author |
Message |
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Sat Sep 01, 2012 6:43 pm Post subject: Text/Code recognition |
|
|
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 |
|
|
Skit3000 Admin Team
Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
|
Back to top |
|
|
bornsoft Contributor
Joined: 19 Feb 2009 Posts: 113 Location: Germany
|
Posted: Mon Nov 05, 2012 1:14 pm Post subject: |
|
|
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 |
|
|
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Mon Nov 05, 2012 9:36 pm Post subject: |
|
|
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 |
|
|
bornsoft Contributor
Joined: 19 Feb 2009 Posts: 113 Location: Germany
|
Posted: Tue Nov 06, 2012 1:35 am Post subject: |
|
|
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
.
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 |
|
|
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
|
Back to top |
|
|
|