From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/72073 Path: news.gmane.org!not-for-mail From: Philipp Gesang Newsgroups: gmane.comp.tex.context Subject: Re: ConvertToConteXt 0.2 - convert special ConTeXt-characters (PHP) Date: Tue, 1 Nov 2011 22:46:41 +0100 Message-ID: <20111101214641.GB18862@aides> References: <4EB0458D.6070108@gmx.de> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0602780105==" X-Trace: dough.gmane.org 1320184030 15024 80.91.229.12 (1 Nov 2011 21:47:10 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 1 Nov 2011 21:47:10 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Tue Nov 01 22:47:04 2011 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RLMAg-0006VK-KK for gctc-ntg-context-518@m.gmane.org; Tue, 01 Nov 2011 22:47:02 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id BAE32CB0AF; Tue, 1 Nov 2011 22:47:00 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 8xmeXbemrdrM; Tue, 1 Nov 2011 22:46:57 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 71F87CB0A8; Tue, 1 Nov 2011 22:46:57 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id E10D2CB0A8 for ; Tue, 1 Nov 2011 22:46:55 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id meVa0R2p0XSx for ; Tue, 1 Nov 2011 22:46:53 +0100 (CET) Original-Received: from filter3-ams.mf.surf.net (filter3-ams.mf.surf.net [192.87.102.71]) by balder.ntg.nl (Postfix) with ESMTP id 4DD7CCB098 for ; Tue, 1 Nov 2011 22:46:53 +0100 (CET) Original-Received: from relay.uni-heidelberg.de (relay.uni-heidelberg.de [129.206.100.212]) by filter3-ams.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id pA1Lkji4004672 for ; Tue, 1 Nov 2011 22:46:48 +0100 Original-Received: from ix.urz.uni-heidelberg.de (cyrus-portal.urz.uni-heidelberg.de [129.206.100.176]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id pA1Lki8M020471 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 1 Nov 2011 22:46:45 +0100 Original-Received: from extmail.urz.uni-heidelberg.de (extmail.urz.uni-heidelberg.de [129.206.100.140]) by ix.urz.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id pA1LkirY009357 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 1 Nov 2011 22:46:44 +0100 Original-Received: from localhost (dslb-188-110-111-173.pools.arcor-ip.net [188.110.111.173]) (authenticated bits=0) by extmail.urz.uni-heidelberg.de (8.13.4/8.13.1) with ESMTP id pA1Lkgjt019111 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Tue, 1 Nov 2011 22:46:43 +0100 Mail-Followup-To: mailing list for ConTeXt users In-Reply-To: <4EB0458D.6070108@gmx.de> X-Operating-System: Linux aides 3.1.0-2-ARCH X-Polite-Request: "Please try to be nice, don't send html mail." User-Agent: Mutt/1.5.20 (2009-06-14) X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=129.206.100.212; country=DE; region=01; city=Heidelberg; latitude=49.4167; longitude=8.7000; http://maps.google.com/maps?q=49.4167,8.7000&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0cFPVKKeL - 0e5854067464 - 20111101 X-Scanned-By: CanIt (www . roaringpenguin . com) on 192.87.102.71 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.12 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:72073 Archived-At: --===============0602780105== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="wq9mPyueHGvFACwf" Content-Disposition: inline --wq9mPyueHGvFACwf Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2011-11-01 20:16, Jan Heinen wrote: > @all: of course not every Character, i am converting, is a > ConTeXt-special-character. Though I don't know all important > characters I took all I could imagine. Shurly I converted > too much however it is no problem: > Which character must not be converted? =C2=B7=C2=B7=C2=B7 from catc-ctx.mkiv =C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7= =C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2= =B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7= =C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7 \startcatcodetable \ctxcatcodes \catcode\tabasciicode \spacecatcode \catcode\endoflineasciicode \endoflinecatcode \catcode\formfeedasciicode \endoflinecatcode \catcode\spaceasciicode \spacecatcode \catcode\endoffileasciicode \ignorecatcode % \catcode\circumflexasciicode\superscriptcatcode % \catcode\underscoreasciicode\subscriptcatcode % \catcode\ampersandasciicode \alignmentcatcode \catcode\underscoreasciicode\othercatcode \catcode\circumflexasciicode\othercatcode \catcode\ampersandasciicode \othercatcode \catcode\backslashasciicode \escapecatcode \catcode\leftbraceasciicode \begingroupcatcode \catcode\rightbraceasciicode\endgroupcatcode \catcode\dollarasciicode \mathshiftcatcode \catcode\hashasciicode \parametercatcode \catcode\commentasciicode \commentcatcode \catcode\tildeasciicode \activecatcode \catcode\barasciicode \activecatcode \stopcatcodetable =C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2= =B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7= =C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2= =B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7= =C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2= =B7=C2=B7=C2=B7 So, afaict, assuming standard catcodes you should be safe with escaping =C2=BB~|\{}$%#=C2=AB (of which the bar was missing in the snippet I posted). Good luck, Philipp >=20 > I had a mistake in the function, below is the next version: >=20 > Regards, Janis >=20 > function ConvertToConteXt ( $xstring ) { > /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > * * * * * > * ConvertToConteXt() > * Version 0.2 > * 01.11.2011 > * > * author: J=C3=B6rg Kopp > * www.dr-kopp.com > * > * Convert special ConTeXt-characters with php > * Works with PHP5 > * > * Call it with the string you want to convert ... > * ConvertToConteXt ($xstring); > * > * ... and you get back the converted string > * > * e.g.: > * Input: > * $string =3D "My root-Directory: /home/hans"; > * $string =3D ConvertToConteXt ( $string ); > * > * Output/Return: > * $string =3D "My root\\char45Directory\\char58 > \\char47home\\char47hans"; > * > * When you write this into a file ... > * file_put_contents ( "example.tex", "My > root\\char45Directory\char58 \\char47home\\char47hans", FILE_APPEND > ); > * > * ... You will find the following in example.tex: > * My root\char45Directory\char58 \char47home\char47hans > * > * An when you compile example.tex with ConTeXt > * context example.text > * > * You can read the following in the resulting example.pdf: > * My root-Directory: /home/hans > * > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > * * * */ >=20 > $xstring =3D html_entity_decode ( $xstring ); // convert > HTML-entities into normal characters >=20 > // Braces and Backslash need to be handled first otherwise trash > will be produced > $xstring =3D str_replace ( "{", "*$##char123##$*", $xstring ); > // geschweifte Klammer auf/left curly brace > $xstring =3D str_replace ( "}", "*$##char125##$*", $xstring ); > // geschweifte Klammer zu/right curly brace > $xstring =3D str_replace ( "\\", "{\\char92}", $xstring ); > // Backslash/backslash > $xstring =3D str_replace ( "*$##char123##$*", "{\\char123}", > $xstring ); // This trick is nessecary ... > $xstring =3D str_replace ( "*$##char125##$*", "{\\char125}", > $xstring ); // ... !!! >=20 > $xstring =3D str_replace ( "!", "{\\char33}", $xstring ); // > Ausrufungszeichen/ConvertToConteXt > $xstring =3D str_replace ( "\"", "{\\char34}", $xstring ); // > Anf=C3=BChrungszeichen/quotation mark > $xstring =3D str_replace ( "#", "{\\char35}", $xstring ); // > Raute/number sign > $xstring =3D str_replace ( "$", "{\\char36}", $xstring ); // > Dollar-Zeichen/dollar sign > $xstring =3D str_replace ( "%", "{\\char37}", $xstring ); // > Prozent-Zeichen/percent sign > $xstring =3D str_replace ( "&", "{\\char38}", $xstring ); // > Kaufm=C3=A4nnisches Und/ampersand > $xstring =3D str_replace ( "'", "{\\char39}", $xstring ); // > Apostroph/apostrophe > $xstring =3D str_replace ( "(", "{\\char40}", $xstring ); // > Klammer auf/left parenthesis > $xstring =3D str_replace ( ")", "{\\char41}", $xstring ); // > Klammer zu/right parenthesis > $xstring =3D str_replace ( "*", "{\\char42}", $xstring ); // > Stern/asterisk > $xstring =3D str_replace ( "+", "{\\char43}", $xstring ); // > Plus/plus sign > $xstring =3D str_replace ( ",", "{\\char44}", $xstring ); // > Komma/comma > $xstring =3D str_replace ( "-", "{\\char45}", $xstring ); // > Minus/hyphen > $xstring =3D str_replace ( ".", "{\\char46}", $xstring ); // > Punkt/period > $xstring =3D str_replace ( "/", "{\\char47}", $xstring ); // > Schr=C3=A4gstrich/period > $xstring =3D str_replace ( ":", "{\\char58}", $xstring ); // > Doppelpunkt/colon > $xstring =3D str_replace ( ";", "{\\char59}", $xstring ); // > Semikolon/semicolon > $xstring =3D str_replace ( "<", "{\\char60}", $xstring ); // > Kleinerzeichen/less-than > $xstring =3D str_replace ( "=3D", "{\\char61}", $xstring ); // > Gleichzeichen/equals-to > $xstring =3D str_replace ( ">", "{\\char62}", $xstring ); // > Gr=C3=B6=C3=9Ferzeichen/greater-than > $xstring =3D str_replace ( "?", "{\\char63}", $xstring ); // > Fragezeichen/question mark > $xstring =3D str_replace ( "@", "{\\char64}", $xstring ); // > at-Zeichen/at sign > $xstring =3D str_replace ( "[", "{\\char91}", $xstring ); // > eckige Klammer auf/left square bracket > $xstring =3D str_replace ( "]", "{\\char93}", $xstring ); // > eckige Klammer zu/right square bracket > $xstring =3D str_replace ( "^", "{\\char94}", $xstring ); // > Zirkumflex/caret > $xstring =3D str_replace ( "_", "{\\char95}", $xstring ); // > Unterstrich/underscore > //$xstring =3D str_replace ( "=C2=B0", "{\\char??}", $xstring ); // > Grad/ < ------ missing > $xstring =3D str_replace ( "`", "{\\char96}", $xstring ); // > accent aigu/acute accent > $xstring =3D str_replace ( "|", "{\\char124}", $xstring ); // > Pipezeichen/vertical bar > $xstring =3D str_replace ( "~", "{\\char126}", $xstring ); // > Tilde/tilde > //$xstring =3D str_replace ( "=E2=80=A2", "{\\char??}", $xstring ); /= / ?/ > < ------ missing > //$xstring =3D str_replace ( "=C2=BA", "{\\char??}", $xstring ); // ?/ > < ------ missing >=20 > return $xstring; > } >=20 > _________________________________________________________________________= __________ > If your question is of interest to others as well, please add an entry to= the Wiki! >=20 > maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-co= ntext > webpage : http://www.pragma-ade.nl / http://tex.aanhet.net > archive : http://foundry.supelec.fr/projects/contextrev/ > wiki : http://contextgarden.net > _________________________________________________________________________= __________ --=20 () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments --wq9mPyueHGvFACwf Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iEYEARECAAYFAk6waMEACgkQ02lYlJYWs9INPACfWhMERuaKR1smkKXkvwSB0/N5 uJAAniXsK2mDgnWMvIMfbB2HGhS4QXlU =B74+ -----END PGP SIGNATURE----- --wq9mPyueHGvFACwf-- --===============0602780105== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ 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 ___________________________________________________________________________________ --===============0602780105==--