1

I have a code:

WCHAR * cmp = L"TEST";

Need a function which would return this string in lower case!

Thanks!

user1262425
  • 299
  • 1
  • 5
  • 17
  • 1
    Good luck modifying that string literal with a predictable result. – dreamlax Mar 11 '12 at 21:00
  • Here's a function that returns the string in lower case: `WCHAR *lowerCase(void) { return L"test"; }` – dreamlax Mar 11 '12 at 21:00
  • possible duplicate of [Converting wide char string to lowercase in C++](http://stackoverflow.com/questions/1614595/converting-wide-char-string-to-lowercase-in-c) – ChrisWue Mar 11 '12 at 21:01
  • I already answered this for you here: http://stackoverflow.com/a/9656257/712358. However, you can't pass `cmp` into that function since it would be read-only. – Mike Kwan Mar 11 '12 at 21:04
  • Mike Kwan, i tried to use your function, but compiler throws error LNK2001: unresolved external symbol __imp_iswlower – user1262425 Mar 11 '12 at 21:10
  • @user1262425: Did you `#include ` or `#include `? – Mike Kwan Mar 11 '12 at 21:25

1 Answers1

4

Based on the WCHAR, you're presumably using (some version of) VC++. In this case, you want to use _wcslwr or _wcslwr_s. You normally do not want to use tolower or toupper on wide character strings.

Jerry Coffin
  • 455,417
  • 76
  • 598
  • 1,067
  • 1
    He probably wants to use `_wcslwr` :P You also might want to add that `towlower` and `towupper` are Unicode equivalents of the two multibyte functions you talk about. – Mike Kwan Mar 11 '12 at 21:07
  • @MikeKwan: _wcslwr is for wide character strings, not multitbyte strings. I considered mentioning towlower, but I don't recall the MS compiler including it (though I haven't looked in a while -- it probably does now). – Jerry Coffin Mar 11 '12 at 21:10
  • I swear I read `_wcsupr` in your original answer! `towlower` is included in `` or ``. – Mike Kwan Mar 11 '12 at 21:24
  • Thanks! I added and but now it throw: error LNK2001: unresolved external symbol __imp_iswctype . I try to add but this file is not included to WDK – user1262425 Mar 11 '12 at 21:29
  • The WDK has a lot of chunks missing from the usual SDK. – dreamlax Mar 11 '12 at 21:53