[Implemented] SendNetworkString() UTF8

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

[Implemented] SendNetworkString() UTF8

Post by Rescator »

Fred, any chance you can change the current SendNetworkString() to behave similar to my SendNetworkStringUTF8() and add a ReceiveNetworkString() similar my ReceiveNetworkStringUTF8() ?

For details/implementation suggestion see:
http://www.purebasic.fr/english/viewtop ... 428#257428

The current one does not handle unicode, only ascii right? And considering that ascii is able to carry UTF8 a new SendNetworkString() will still remain backwards compatible with old/current ascii programs. As for old unicode programs...those are broken anyway with the old SendNetworkString() :P
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post by Rescator »

Considering how robust this would be, might I also suggest a #PB_NetworkEvent_String=5 :wink:
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post by dracflamloc »

The string function was just a convenience function. You don't send 'strings' over the network, just bytes. You can send unicode string same way as normal strings, as sequences of bytes. ReceiveNetworkString would make no sense and there'd be no good way of knowing if the bytes being received were supposed to be a string, let alone what type of string.
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post by Rescator »

Did you see my example in the other thread?
All strings are treated as UTF8, 99% of all ascii will be accepted as-is by UTF8 so hardly an issue.

Also, there is a send/receive File currently.

I think that send/receive file, + send/receive data, + send/receive text, would be a nice trio of network functions, especially if strings are given a event flag. That way a game client/server can react to the event type. obviously a server in particular but a client as well should always check if the received data, whether it is data, a file or a string that is valid. But it does allow a virtual 3 channel data transfer. (raw data, file data, string data)

send/receivefile already uses a safe marker to indicate it's a file and not raw data, shouldn't be much harder to do the same with strings if the strings are made to be UTF8 which is platform and byteorder independent.
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post by dracflamloc »

Well, I suppose since I was against SendNetworkFile as well...

If this is to be the path of the pb netlib I think a settable option should be allowed in initnetwork() to disable any receive events except data, to allow for more 'pure' use
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

Dang... I found this one and was gonna post it! :wink: Thanks Rescator... thanks for the workaround as well!
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post by Rescator »

Well! I guess you could still post a bug report. But I'm assuming the PB Team are well aware of this now :)
Post Reply