TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

What are TCHAR, WCHAR, LPSTR, LPWSTR, LPCTSTR?

2 pointsby akandiahalmost 11 years ago

2 comments

bklimtalmost 11 years ago
&quot;In general, a character can be represented in 1 byte or 2 bytes. Let&#x27;s say 1-byte character is ANSI character - all English characters are represented through this encoding. And let&#x27;s say a 2-byte character is Unicode, which can represent ALL languages in the world.&quot;<p>No. A character can be three or four bytes. I think he meant ASCII, not ANSI. And no, two byte characters are not &quot;Unicode&quot;. I feel like this article might do a disservice to folks who aren&#x27;t totally clear about Unicode before theyread it. I would strongly recommend reading Joel Spolsky&#x27;s &quot;The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)&quot; and being totally clear on that before trying to read this.
lsh123almost 11 years ago
This is really simple (I don&#x27;t write code for Windows for more than 7 years but I still remember it):<p>CHAR - standard C character (one byte)<p>WCHAR - two bytes Unicode character<p>TCHAR - either CHAR or WCHAR depending on your compiler options (hint: all Windows system functions have both versions to support ASCII or Unicode and this is an easy way to write code once)<p>LPXXX - &quot;long pointer&quot; to XXX (&quot;long&quot; comes from the old times, just ignore - this is a pointer)<p>LPCXXX - &quot;long pointer&quot; to a constant string (in C you can&#x27;t just do &quot;const LPXXX&quot; since it will mean the pointer itself is constant, thus the &quot;const&quot; keyword should actually be &quot;inside&quot; the definition)