S. Braun
S. Braun

Reputation: 143

Sending foreign characters in c

I tested this but it won't work. The foreign characters get lost.

char message [] = "stringtobesendedwithforeigncharacters도쿄";

t = 39;

while(curler < t) {
    r = send(sockfd, message, t, 0);
    if(r > 0) {
        curler += r;
    }
}

What's the easiest way to do this?

Upvotes: 0

Views: 151

Answers (3)

mikithskegg
mikithskegg

Reputation: 816

Use wchar_t instead of char and functions for this type.

Upvotes: 0

LihO
LihO

Reputation: 42093

You have a typo in message declaration and you assign incorrect size to t as other guys have already pointed out.

This article will maybe help you: Unicode in C and C++: What You Can Do About It Today

Upvotes: 2

Michael Krelin - hacker
Michael Krelin - hacker

Reputation: 143119

Try

char message[] = "stringtobesendedwithforeigncharacters도쿄";
t = sizeof(message)-1;

for starters.

Upvotes: 2

Related Questions