Hello, I have problem with testing of strings through \doifelse. I am loading data from external CSV file. CSV file is UTF-8 encoding. Data from external file I am reading to ConTeXt macro and I want compare content of macro (it is one utf-8 character) and other character as per example: (\onecharfromcsvfile contains one character from external CSV file) % I compare e.g. "m" character and content of macro \onecharfromcsvfile \def\result{\doifelse{m}{\onecharfromcsvfile}{true}{false} } \result is however always false When CSV file is CP-1250 encoding then macro does work right as well as classical TeX macro: \def\result{\if m\onecharfromcsvfile true\else false \fi} My question is: Just how modify macro as to work right when CSV file is UTF-8 encoding. Thanx Jaroslav PS: I was working up until now only with CP-1250 encoding, but when I started with LuaTeX (MKIV), then I have to use UTF-8. (MKIV dont work corectly with external CP-1250 files).
Jaroslav Hajtmar wrote:
Hello, I have problem with testing of strings through \doifelse.
I am loading data from external CSV file. CSV file is UTF-8 encoding. Data from external file I am reading to ConTeXt macro and I want compare content of macro (it is one utf-8 character) and other character as per example:
(\onecharfromcsvfile contains one character from external CSV file)
Does it contain a character or a byte from the CSV? This is a very important difference.
% I compare e.g. "m" character and content of macro \onecharfromcsvfile \def\result{\doifelse{m}{\onecharfromcsvfile}{true}{false} }
\result is however always false
Well, that depends on whether m's in your csv file, and how \onecharfromcvsfile is actually defined. This reports true: \starttext \def\onecharfromcsvfile{m} \def\result{\doifelse{m}{\onecharfromcsvfile}{true}{false} } \result \stoptext Best wishes, Taco
Hello. Thank for your advise. I was tried your example, but it is not working unfortunately too. I previwed CSV file - it is UTF-8 encoding and hexa code of "m" character is 6D00. This mean that "m" char is byte coding isnt it? Exist any way untwist my problem now? Thanx Jaroslav In hexa editor is Dne 22.4.2010 21:33, Taco Hoekwater napsal(a):
Jaroslav Hajtmar wrote:
Hello, I have problem with testing of strings through \doifelse.
I am loading data from external CSV file. CSV file is UTF-8 encoding. Data from external file I am reading to ConTeXt macro and I want compare content of macro (it is one utf-8 character) and other character as per example:
(\onecharfromcsvfile contains one character from external CSV file)
Does it contain a character or a byte from the CSV? This is a very important difference.
% I compare e.g. "m" character and content of macro \onecharfromcsvfile \def\result{\doifelse{m}{\onecharfromcsvfile}{true}{false} }
\result is however always false
Well, that depends on whether m's in your csv file, and how \onecharfromcvsfile is actually defined. This reports true:
\starttext \def\onecharfromcsvfile{m} \def\result{\doifelse{m}{\onecharfromcsvfile}{true}{false} } \result \stoptext
Best wishes, Taco
Jaroslav Hajtmar wrote:
Hello. Thank for your advise. I was tried your example, but it is not working unfortunately too. I previwed CSV file - it is UTF-8 encoding and hexa code of "m" character is 6D00. This mean that "m" char is byte coding isnt it?
The hex codes of all your 'm'-s in the email messages are 6D, which is UTF-8 for the ASCII m. Sorry, please post a proper example, I don't think we can help without actual input. Best wishes, Taco
Will help you, when I send you my CSV file? I dont now what you think when you writing, that you want "actual input". Code 6D00 is twobyte code of UTF-8 character "m"... When I switch to CP1250 encoding, then onebyte code of "m" character is 6D. If need arises then I make any minimal example from my relatively big project. Thanx. Jaroslav Dne 22.4.2010 21:59, Taco Hoekwater napsal(a):
Jaroslav Hajtmar wrote:
Hello. Thank for your advise. I was tried your example, but it is not working unfortunately too. I previwed CSV file - it is UTF-8 encoding and hexa code of "m" character is 6D00. This mean that "m" char is byte coding isnt it?
The hex codes of all your 'm'-s in the email messages are 6D, which is UTF-8 for the ASCII m. Sorry, please post a proper example, I don't think we can help without actual input.
Best wishes, Taco
On 22-4-2010 8:57, Jaroslav Hajtmar wrote:
Hello, I have problem with testing of strings through \doifelse.
I am loading data from external CSV file. CSV file is UTF-8 encoding. Data from external file I am reading to ConTeXt macro and I want compare content of macro (it is one utf-8 character) and other character as per example:
(\onecharfromcsvfile contains one character from external CSV file)
% I compare e.g. "m" character and content of macro \onecharfromcsvfile \def\result{\doifelse{m}{\onecharfromcsvfile}{true}{false} }
\result is however always false
When CSV file is CP-1250 encoding then macro does work right as well as classical TeX macro:
\def\result{\if m\onecharfromcsvfile true\else false \fi}
My question is: Just how modify macro as to work right when CSV file is UTF-8 encoding.
tricky as utf in mkii is using active chars ... it all depends a bit to what the character expands; depending on the macro one can also use \convertargument#1\to\whatever like constructs and then compare the \whatever
Thanx Jaroslav
PS: I was working up until now only with CP-1250 encoding, but when I started with LuaTeX (MKIV), then I have to use UTF-8. (MKIV dont work corectly with external CP-1250 files).
oh? regimes are supposed to work ok in mkiv Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Thank you very much. Due to your suggestion it was my problem resolved. Problem has been truly in unexpanded macros. Though I am redefining my macros in last versions of my project (joining any empty delimiters), macros was predend (on the outside as expanded) entirely inocently as if has been unchanged. It was beginners perplexing mistake - but heavy detecting (for me). Thankx for your and Tacos time. Jaroslav Dne 22.4.2010 23:28, Hans Hagen napsal(a):
On 22-4-2010 8:57, Jaroslav Hajtmar wrote:
Hello, I have problem with testing of strings through \doifelse.
I am loading data from external CSV file. CSV file is UTF-8 encoding. Data from external file I am reading to ConTeXt macro and I want compare content of macro (it is one utf-8 character) and other character as per example:
(\onecharfromcsvfile contains one character from external CSV file)
% I compare e.g. "m" character and content of macro \onecharfromcsvfile \def\result{\doifelse{m}{\onecharfromcsvfile}{true}{false} }
\result is however always false
When CSV file is CP-1250 encoding then macro does work right as well as classical TeX macro:
\def\result{\if m\onecharfromcsvfile true\else false \fi}
My question is: Just how modify macro as to work right when CSV file is UTF-8 encoding.
tricky as utf in mkii is using active chars ... it all depends a bit to what the character expands; depending on the macro one can also use
\convertargument#1\to\whatever like constructs and then compare the \whatever
Thanx Jaroslav
PS: I was working up until now only with CP-1250 encoding, but when I started with LuaTeX (MKIV), then I have to use UTF-8. (MKIV dont work corectly with external CP-1250 files).
oh? regimes are supposed to work ok in mkiv
Hans
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On Fri, Apr 23, 2010 at 00:30, Jaroslav Hajtmar wrote:
Thank you very much. Due to your suggestion it was my problem resolved. Problem has been truly in unexpanded macros.
Can the solution be applied to the m-database.tex module as well? Last time when I tried the UTF-8 didn't work with mkii (if the first character in cell wasn't an ascii character). Mojca Example: \enableregime[utf-8] \usemodule[database] \defineseparatedlist[CSV] [separator=comma, before=\bTABLE, after=\eTABLE, first=\bTR, last=\eTR, left=\bTD, right=\eTD] \starttext \startCSV a,b,c,č d,e,f,š \stopCSV \stoptext
On 23-4-2010 2:31, Mojca Miklavec wrote:
On Fri, Apr 23, 2010 at 00:30, Jaroslav Hajtmar wrote:
Thank you very much. Due to your suggestion it was my problem resolved. Problem has been truly in unexpanded macros.
Can the solution be applied to the m-database.tex module as well?
Last time when I tried the UTF-8 didn't work with mkii (if the first character in cell wasn't an ascii character).
Mojca
Example:
\enableregime[utf-8] \usemodule[database] \defineseparatedlist[CSV] [separator=comma, before=\bTABLE, after=\eTABLE, first=\bTR, last=\eTR, left=\bTD, right=\eTD] \starttext \startCSV a,b,c,č d,e,f,š \stopCSV \stoptext ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
-- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On 23-4-2010 2:31, Mojca Miklavec wrote:
Last time when I tried the UTF-8 didn't work with mkii (if the first character in cell wasn't an ascii character).
another trick: \bgroup \keeputfcharacters \doifelse{slovenian mkii utf} {whatever} {\egroup ..} {\egroup ..} ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (4)
-
Hans Hagen
-
Jaroslav Hajtmar
-
Mojca Miklavec
-
Taco Hoekwater