X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org MIME-Version: 1.0 Date: Sun, 9 Aug 2009 12:42:04 +0100 Message-ID: <416096c60908090442j6b238c0fte0d6d20960524a6b@mail.gmail.com> Subject: UTF-16 surrogate macros From: Andy Koppe To: Cygwin Tech List Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com w32api/winnls.h is lacking the macros for recognising UTF-16 surrogates: IS_HIGH_SURROGATE, IS_LOW_SURROGATE, IS_SURROGATE_PAIR. Here's one way to define them, which avoids evaluating the characters twice: #define IS_HIGH_SURROGATE(c) (((c) & 0xFC00) == 0xD800) #define IS_LOW_SURROGATE(c) (((c) & 0xFC00) == 0xDC00) #define IS_SURROGATE_PAIR(hc,lc) (IS_HIGH_SURROGATE(hc) && IS_LOW_SURROGATE(lc)) Andy -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple