Created
January 3, 2015 17:26
-
-
Save femtotrader/4e55ffa4d67bbf97e0ed to your computer and use it in GitHub Desktop.
String toolbox for Metatrader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//+------------------------------------------------------------------+ | |
//| string_toolbox.mqh | | |
//| Copyright © 2014, FemtoTrader | | |
//| https://sites.google.com/site/femtotrader/ | | |
//+------------------------------------------------------------------+ | |
#property copyright "Copyright © 2014, FemtoTrader" | |
#property link "https://sites.google.com/site/femtotrader/" | |
#property version "1.00" | |
//+------------------------------------------------------------------+ | |
//| Enclose string with simple quote (') | | |
//+------------------------------------------------------------------+ | |
string quote(string s) | |
{ | |
return("'" + s + "'"); | |
} | |
//+------------------------------------------------------------------+ | |
//| Enclose string with doublequote (") | | |
//+------------------------------------------------------------------+ | |
string doublequote(string s) | |
{ | |
return("\"" + s + "\""); | |
} | |
//+------------------------------------------------------------------+ | |
//| Enclose string with backquote (`) | | |
//| "backquote" are also called "backtick" | | |
//+------------------------------------------------------------------+ | |
string backquote(string s) | |
{ | |
return("`" + s + "`"); | |
} | |
//+------------------------------------------------------------------+ | |
//| Trim a string left and right | | |
//+------------------------------------------------------------------+ | |
string StringTrim(string str) | |
{ | |
str = StringTrimLeft(str); | |
str = StringTrimRight(str); | |
return (str); | |
} | |
//+------------------------------------------------------------------+ | |
//| Unescape string | | |
//+------------------------------------------------------------------+ | |
string string_unescape(string s) | |
{ | |
StringReplace(s,"_ESC1_","'"); | |
StringReplace(s,"_ESC2_","\""); | |
return(s); | |
} | |
//+------------------------------------------------------------------+ | |
//| Escape string | | |
//+------------------------------------------------------------------+ | |
string string_escape(string s) | |
{ | |
StringReplace(s,"'","_ESC1_"); | |
StringReplace(s,"\"","_ESC2_"); | |
return(s); | |
} | |
//+------------------------------------------------------------------+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment