ObjCSV_Format4CSV()

Add encapsulator before and after strF4C if the string includes line breaks, field delimiter or field encapsulator. Encapsulated field encapsulators are doubled.

ObjCSV_Format4CSV(strF4C [, strFieldDelimiter = ",", strEncapsulator = """"])

Parameters

strF4C String to convert to CSV format
strFieldDelimiter (Optional) Field delimiter. One character, usually comma (default value) or tab.
strEncapsulator (Optional) Character (usualy double-quote) used in the CSV file to embed fields that include at least one of these special characters: line-breaks, field delimiters or the encapsulator character itself. In this last case, the encapsulator character must be doubled in the string. For example: "one ""quoted"" word". Double-quote by default.
blnAlwaysEncapsulate (Optional) If true (or 1), always encapsulate values with field encapsulator. If false (or 0), fields are encapsulated only if required (see strEncapsulator above). False (or 0) by default.

Returns

String with required encapsulator.

Remarks

Based on Format4CSV by Rhys (http://www.autohotkey.com/forum/topic27233.html).

Added the strFieldDelimiter parameter to make it work with separators other than comma.
Added the strEncapsulator parameter to make it work with other encapsultors than double-quotes.