From 900a92e1158cb178335d16ff0912f5fc5701da32 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 23 Jan 2009 19:49:22 -0400 Subject: Added support for Unicode text in Ledger files, thanks to 'utfcpp', which can be located at http://utfcpp.sourceforge.net. --- src/textual.cc | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'src/textual.cc') diff --git a/src/textual.cc b/src/textual.cc index e1a08f69..4600f3f3 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -596,10 +596,16 @@ static inline void parse_symbol(char *& p, string& symbol) bool textual_parser_t::test(std::istream& in) const { - char buf[5]; + char buf[12]; + char * p; - in.read(buf, 5); - if (std::strncmp(buf, " account_stack; auto_entry_finalizer_t auto_entry_finalizer(&journal); @@ -714,10 +721,15 @@ unsigned int textual_parser_t::parse(std::istream& in, while (in.good() && ! in.eof()) { try { - in.getline(line, MAX_LINE); + in.getline(linebuf, MAX_LINE); if (in.eof()) break; + if (linenum == 1 && utf8::is_bom(linebuf)) + line = &linebuf[3]; + else + line = linebuf; + int len = std::strlen(line); if (line[len - 1] == '\r') line[--len] = '\0'; -- cgit v1.2.3