Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TCHAR Strings and concatonation issues

Status
Not open for further replies.

TheBoyMonkey

Programmer
Nov 24, 2003
11
FR
I'm trying to retrieve a few lines of text from a file (ASCII) and then concatonate them into a TCHAR variable.

The entire lines of text amount to around 170 characters in length and the TCHAR receiving each file line is is set to _TCHAR fileLine[4000].

I'm simply using the instruction:

_tcscat(*completeString, fileLine);

to concatonate.

The problem is that the line concatonations stop after around 150 characters for no real reason that I can see (and halfway through a fileLine), even thought the _TCHAR fileLine variable continues to hold the whole of the next string in sequence correctly.

If I use strcat and char variables, the completeString is built correctly, but the same problem occurs if I try to convert to TCHAR (in the same place of the string).

Any ideas?

Thanks for any time,
Tom.
 
What complie options are you using ([tt]_MBCS[/tt], [tt]_UNICODE[/tt], etc.) for character set encoding?

If you're compiling with [tt]_UNICODE[/tt], then just reading ASCII (8-bit characters) into the [tt]TCHAR[/tt] variable doesn't convert ASCII to UNICODE, and it will treat every pair of ASCII characters as a single UNICODE character. The fact that [tt]strcat[/tt] works in your program seems to suggest that this is the case.

[tt]________________________________________________________________
[pc2]Roger
Life is a game of cards in which the deck contains only jokers.[/tt]
 
If you are using _UNICODE you will want to

#include <atlconv.h>

...
USES_CONVERSION
_tcscat(*completString,A2T(fileLine));

also, memset completeString to zero just incase the null terminator does not come along. I always do this because I read somewhere that some str functions do not bring this along.

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top