@Override
	public void toFtanML(Writer writer) {
		try {
			//Calculate count of double quotation marks (") and single quotation marks (') in the string
			int numberDQuotes = 0;
			int numberSQuotes = 0;
			for (int i=0;i<value.length();++i) {
				switch (value.charAt(i)) {
				case '"':
					++numberDQuotes;
					break;
				case '\'':
					++numberSQuotes;
					break;
				}
			}
			//Use the quotation mark that causes less escaping
			char usedQuote = (numberDQuotes<=numberSQuotes)?'"':'\'';
			//Output the escaped string
			writer.append(usedQuote + escape(value, usedQuote) + usedQuote);
			
		} catch (IOException e) {
			throw new IllegalStateException(e);
		}
	}