From owner-freebsd-hackers@freebsd.org Sat Apr 3 10:22:55 2021 Return-Path: Delivered-To: freebsd-hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5F4405C72FF for ; Sat, 3 Apr 2021 10:22:55 +0000 (UTC) (envelope-from yuripv@yuripv.dev) Received: from mailman.nyi.freebsd.org (mailman.nyi.freebsd.org [IPv6:2610:1c1:1:606c::50:13]) by mx1.freebsd.org (Postfix) with ESMTP id 4FCCfl14l4z3mcr for ; Sat, 3 Apr 2021 10:22:55 +0000 (UTC) (envelope-from yuripv@yuripv.dev) Received: by mailman.nyi.freebsd.org (Postfix) id 244CB5C72FE; Sat, 3 Apr 2021 10:22:55 +0000 (UTC) Delivered-To: hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 240585C78E6 for ; Sat, 3 Apr 2021 10:22:55 +0000 (UTC) (envelope-from yuripv@yuripv.dev) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4FCCfl03xmz3mwP; Sat, 3 Apr 2021 10:22:54 +0000 (UTC) (envelope-from yuripv@yuripv.dev) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 62B485C009A; Sat, 3 Apr 2021 06:22:54 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sat, 03 Apr 2021 06:22:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yuripv.dev; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=F wJbzdSy/ZY1uarHMUcVnwvCOi7Uv+xjXz8Y3oloRnE=; b=lLUZ5f55BvZnOhEE+ FCmg9vCv6y2VEqwVYvxVi5J6bpbPuWB5tWG+tCnBsY83yEjTtH6xpuQR2nFq+po1 hhzApY/1njEz9n4SCoNldWNg/nqnmCa2vx1OcnwQ1jUjKin2xigBOj3Vi8zEYCrj x6JMuyi4t/IoERTCfi8X8GYvWXc/XhHg8sZcFrtQcAgWnyDuq3BD05aqa0f1xrW9 Zlk9e9kR4ZrxDmDrPucK3gi273yXneEnuivBiVqRyhPUwCw7CS/zQqRvnvGagrH1 FfNIVKgp10b0PGZ9f4/JZ1XIA6gtxghNslrjSB5v9X9Yh5EEe2GzlALhXNegdQZ3 OC4Rw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=FwJbzdSy/ZY1uarHMUcVnwvCOi7Uv+xjXz8Y3oloR nE=; b=coFUwrL4maXqmspt0mlvyJ0FDc+qj+fVg7LH94V3PMf6wEnLu2NzqWj5r ohufy2QPazI8NLov+PdQ/IxnTzqMcePVLMtPHxRUzIGiMsA+INkrFXePZNJYgSH2 l5Z9ad/nsZ0qQhiF5gIYnzZ1GiHnIvR0/ThN+yxWpQ+BbEuf/onnDWg4i39JnTcf pRYDm89JBpSB2H1xAyLCCvY7j7NDMoJh1x7ON1kxWlQ6MjNPUrfr2meHyFiP7xdk a4mby0IO8gqyn/xhrEuBTLFT5+gzP7XH4QZ5oMz8xz6f5WBkHCCpqsr4qPmMUw/h P3khnsoTLYAgWa0/kFgjX/5YegLmw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudeikedgfeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthejredttdefjeenucfhrhhomhepjghurhhi ucfrrghnkhhovhcuoeihuhhrihhpvheshihurhhiphhvrdguvghvqeenucggtffrrghtth gvrhhnpeffhedvkeegieejveelvdffgfevueevgffgjefhleeuueevtedvvddvgfeiteff teenucfkphepledurddvgedtrdduvdegrddufeejnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhephihurhhiphhvseihuhhrihhpvhdruggvvh X-ME-Proxy: Received: from [192.168.1.12] (unknown [91.240.124.137]) by mail.messagingengine.com (Postfix) with ESMTPA id 3DA80240054; Sat, 3 Apr 2021 06:22:53 -0400 (EDT) Subject: Re: wcwidth() and wcswidth() and Latin vs. CJK character width To: Alexey Dokuchaev , Ed Maste Cc: hackers@freebsd.org References: <20210324143117.GA61738@regency.nsu.ru> <20210403063423.GA50619@regency.nsu.ru> From: Yuri Pankov Message-ID: Date: Sat, 3 Apr 2021 13:22:50 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: <20210403063423.GA50619@regency.nsu.ru> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4FCCfl03xmz3mwP X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Technical discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Apr 2021 10:22:55 -0000 Alexey Dokuchaev via freebsd-hackers wrote: > On Fri, Apr 02, 2021 at 04:51:49PM -0400, Ed Maste wrote: >> On Wed, 24 Mar 2021 at 10:37, Alexey Dokuchaev via freebsd-hackers >> wrote: >>> I've been wondering if there's anything like Markus Kuhn's >>> implementation* in our base libraries for $subj (my quick naive >>> search didn't turn up any results). If yes, could someone point >>> me at it? >> >> Kuhn's implementation is in the kernel for teken >> (sys/teken/teken_wcwidth.h). But, wcwidth/wcswidth are available >> already in userland, > > Our default wcwidth(3) does not seem to work as described, but then > I've found that Kuhn's code is also part of the libxo(3) which what > I should have probably used in the first place. > >> is there some reason you are looking at Kuhn's implementation >> specifically? > > I want to improve the "ifconfig wlan0 list scan" output, e.g. it > currently does not display SSIDs which are in Russian or CJK, but > conversion to libxo(3) would address both this problem and make > the output easily consumable by external tools. I think this could be easily fixed by adding setlocale(LC_ALL, "") call to ifconfig's main(), wcwidth() won't work properly without correct locale set (at least, without LC_CTYPE).