Skip to content

Instantly share code, notes, and snippets.

@petrowsky
Last active August 29, 2015 14:01
Show Gist options
  • Save petrowsky/12f818485a2bff992262 to your computer and use it in GitHub Desktop.
Save petrowsky/12f818485a2bff992262 to your computer and use it in GitHub Desktop.
<pre>
\foo
\\bar
"\foo¶\\\bar"
"\"\foo\¶\\\\\bar\""
"\"\\\"\foo\\\¶\\\\\\\\\bar\\\"\""
"\"\\\"\\\\\\\"\foo\\\\\\\¶\\\\\\\\\\\\\\\\\bar\\\\\\\"\\\"\""
"\"\\\"\\\\\\\"\\\\\\\\\\\\\\\"\foo\\\\\\\\\\\\\\\¶\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\bar\\\\\\\\\\\\\\\"\\\\\\\"\\\"\""
"\"\\\"\\\\\\\"\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\foo\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\¶\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\bar\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\"\\\\\\\"\\\"\""
"\"\\\"\\\\\\\"\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\foo\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\¶\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\bar\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\"\\\\\\\"\\\"\""
</pre>
<?php
function fmQuote ($value) {
return '"' . str_replace(array('\\', '"', '¶', "\n"), array('\\\\', '\"', '\\¶', '¶'), $value) . '"';
}
$val = "\\foo\n\\\\bar";
echo '<pre>';
echo $val;
echo "\n\n";
echo fmQuote ($val);
echo "\n";
echo fmQuote (fmQuote ($val));
echo "\n";
echo fmQuote (fmQuote (fmQuote ($val)));
echo "\n";
echo fmQuote (fmQuote (fmQuote (fmQuote ($val))));
echo "\n";
echo fmQuote (fmQuote (fmQuote (fmQuote (fmQuote ($val)))));
echo "\n";
echo fmQuote (fmQuote (fmQuote (fmQuote (fmQuote (fmQuote ($val))))));
echo "\n";
echo fmQuote (fmQuote (fmQuote (fmQuote (fmQuote (fmQuote (fmQuote ($val)))))));
echo '</pre>';
?>
<pre>
FileMaker testing code
----------------------
Let ( [
~value = "\\foo¶\\\\bar"
];
List (
~value;
Quote ( ~value );
Quote ( Quote ( ~value ));
Quote ( Quote ( Quote ( ~value )));
Quote ( Quote ( Quote ( Quote ( ~value ))));
Quote ( Quote ( Quote ( Quote ( Quote ( ~value )))));
Quote ( Quote ( Quote ( Quote ( Quote ( Quote ( ~value ))))));
Quote ( Quote ( Quote ( Quote ( Quote ( Quote ( Quote ( ~value )))))));
)
)
</pre>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment