Skip to content

Latest commit

 

History

History
56 lines (50 loc) · 1.17 KB

File metadata and controls

56 lines (50 loc) · 1.17 KB
title Character Comparison | Microsoft Docs
ms.custom
ms.date 11/04/2016
ms.reviewer
ms.suite
ms.technology
cpp-windows
ms.tgt_pltfrm
ms.topic article
dev_langs
C++
helpviewer_keywords
comparing characters
MBCS [C++], character comparison
characters [C++], comparing
ms.assetid 18846e44-3e6e-40c4-9b42-3153fb15db20
caps.latest.revision 8
author ghogen
ms.author ghogen
manager ghogen
translation.priority.ht
cs-cz
de-de
es-es
fr-fr
it-it
ja-jp
ko-kr
pl-pl
pt-br
ru-ru
tr-tr
zh-cn
zh-tw

Character Comparison

Use the following tips:

  • Comparing a known lead byte with an ASCII character works correctly:

    if( *sz1 == 'A' )  
    
  • Comparing two unknown characters requires the use of one of the macros defined in Mbstring.h:

    if( !_mbccmp( sz1, sz2) )  
    

    This ensures that both bytes of a double-byte character are compared for equality.

See Also

MBCS Programming Tips
Buffer Overflow