[Implemented] ReadCharacter(#File, [, Flags])

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

[Implemented] ReadCharacter(#File, [, Flags])

Post by Tenaja »

Fred & Freak, can you please add the same file format flags to ReadCharacter() that are in ReadString()?

I am making my code Unicode friendly, but I need to be able to read ascii and utf-8 files as well, based on the file type.

thanks.
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: ReadCharacter(#File, [, Flags])

Post by Fred »

Good idea. In the meantime, you can use ReadString() with a length of 1.
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: ReadCharacter(#File, [, Flags])

Post by STARGÅTE »

@Fred
With this flag you can remove the functions: ReadUnicodeCharacter() and ReadAsciiCharacter()
Same for WriteCharacter()

And same for PokeC() and PeekC() ?
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: ReadCharacter(#File, [, Flags])

Post by Tenaja »

Fred wrote:Good idea. In the meantime, you can use ReadString() with a length of 1.
Thank you. (And if you saw my other post, you will see I am using ReadString, but it is slow compared to readcharacter, which is noticeable in very large files.

As Stargate suggested, perhaps you can implement it in other string and character related commands...where it makes sense, of course. This update will make the elimination of ascii strings significantly easier to deal with.
Last edited by Tenaja on Thu Aug 14, 2014 5:16 pm, edited 1 time in total.
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: ReadCharacter(#File, [, Flags])

Post by skywalk »

Please don't remove PeekC/PokeC. That breaks macros and requires even more code changes.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: ReadCharacter(#File, [, Flags])

Post by Tenaja »

skywalk wrote:Please don't remove PeekC/PokeC. That breaks macros and requires even more code changes.
Considering his pattern of previous edits, I think Fred is more likely to change the syntax from this:
PeekC(*MemoryBuffer)
To this:
PeekC(*MemoryBuffer [, Flags])
An edit which will not break existing code.

BTW, I have posted a workaround that does not create a string, by creating a ReadUTF8Character routine. It may or may not be faster; I guess I'd have to benchmark it to tell:
http://purebasic.fr/english/viewtopic.php?f=12&t=60273
Post Reply