From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16654 invoked by alias); 2 Mar 2011 10:38:11 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 15833 Received: (qmail 26930 invoked from network); 2 Mar 2011 10:37:59 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00,DEAR_SOMETHING, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, T_TO_NO_BRKTS_FREEMAIL autolearn=no version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.210.171 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:date:from:to:subject:message-id :mail-followup-to:references:mime-version:content-type :content-disposition:content-transfer-encoding:in-reply-to :disposition-notification-to:user-agent; bh=kynbM/S8SqEvxPP+d+Aq52hDtjVgCRlKu3+9i8I9kJA=; b=okF+4WcGlh3rI1cR+xOXeaDZerRLocmPaWgeQJTAtFZKwRdVLiw8CrEzTZAUhWPdYT yiLfUAgWk/6AyILIGzYBx1hoBzKid9TvhkjughvDeWZqkqfM4E4qyMr3w2R6Kyao6KOT L4Pvn7yclNjK6M9DYSZGRIXZWJa/9BkI2pBwQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition :content-transfer-encoding:in-reply-to:disposition-notification-to :user-agent; b=Hpb9QgzAKeBqdevtwJRplZxhKGafIQr62RvOqAN/Au5KlRvhYRWFN4SNFif8n+wmHQ 0CnQ/+/3TOEOhMX71dLYsLYZ1FIhYnN9JsriCBGwtTEHAOzLUx+Va1r3XtP1e7dVNN0M odnP1qsMSyYmpbvNskE2wzAIWv9sCYdPTCBPk= Date: Wed, 2 Mar 2011 18:37:05 +0800 From: lilydjwg To: zsh-users@zsh.org Subject: Re: Fw: ZSH history file VS. UTF-8 data Message-ID: <20110302103705.GA11422@lilydjwg.info> Mail-Followup-To: zsh-users@zsh.org References: <20110302094336.62001793@pwslap01u.europe.root.pri> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="PNTmBPCT7hxwcZjr" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20110302094336.62001793@pwslap01u.europe.root.pri> User-Agent: Mutt/1.5.20 (2009-06-14) --PNTmBPCT7hxwcZjr Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Wed, Mar 02, 2011 at 09:43:36AM +0000, Peter Stephenson wrote: > I got this. I haven't investigated. Replies will need to be copied > directly. > > > Begin forwarded message: > > Date: Wed, 2 Mar 2011 11:49:29 +0900 > From: ıɥɔıɐʇ ɐʇɐqɐʍɐʞ > To: > Subject: ZSH history file VS. UTF-8 data > > > Dear sir, > > I'm sorry to disturb you. > > I've been a user of ZSH for a long time and I really > appreciate for the developer of this great software. > > Recently, I've got one trouble in ZSH history file, and as I tried to > solve it by > surveying Webs and Sources, with no help. As of it, knowing that this > disturbs you, > I'm trying to ask for any help. > > The trouble is as follows: > > When I try to use UTF-8 file name in shell command, ZHS history file > seems to save > it with "meta code". > > For example, executing > $ ls \346\226\207\345\255\227 (octal expression of "ls 文字”) > results in histfile > $ ls \346\203\266\203\247\2\345\255\203\267 > > That is, when 0x80-0x9F characters are used, then always 0x83 Meta > character is inserted and following character is bit shifted, resulting > garbage history. > > Any way to avoid this situation? > > Any help is really appreciated, > I met the same problem, and had a look at the zsh source code, attached is the C program I use to deal with this. However, I have not found an option to turn this feature off or why the history file is encoded in this way. -- Best regards, lilydjwg Linux Vim Python 我的博客 http://lilydjwg.is-programmer.com/ --PNTmBPCT7hxwcZjr Content-Type: text/x-csrc; charset=utf-8 Content-Disposition: attachment; filename="zhist.c" Content-Transfer-Encoding: 8bit //===================================================================== // 让 zsh 的历史记录可读 //===================================================================== #include #include #include #include //--------------------------------------------------------------------- void readhist(); void writehist(); void usage(); static int ismeta(unsigned char ch); //--------------------------------------------------------------------- int main(int argc, char** argv){ if(argc == 1) readhist(); else if(argc == 2){ if(!strcmp(argv[1], "read")) readhist(); else if(!strcmp(argv[1], "write")) writehist(); else usage(); }else usage(); return 0; } void readhist(){ unsigned char c, d; int change = 0; while(read(0, &c, 1)){ if(c != 0x83){ if(change){ d = c ^ 32; }else d = c; write(1, &d, 1); change = 0; }else change = 1; } } void writehist(){ unsigned char c, d; while(read(0, &c, 1)){ if(ismeta(c)){ d = 0x83; write(1, &d, 1); d = c ^ 32; write(1, &d, 1); }else write(1, &c, 1); } } void usage(){ fprintf(stderr, "Usage: zhist [read|write]\n" "\tzhist reads from stdin and outputs to stdout, " "with the content changes\nto be read by human being " "or by the zsh program.\n"); exit(1); } static int ismeta(unsigned char ch){ return (ch > 0x83 && ch < 0x9e) || ch == 0xa0 || ch == 0x83 || ch == 0; } //===================================================================== --PNTmBPCT7hxwcZjr--