Skip to content

Commit

Permalink
Fix string writing for StreamWriter
Browse files Browse the repository at this point in the history
  • Loading branch information
LunaTheFoxgirl committed Jun 1, 2024
1 parent 3e66c3e commit a875fa4
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions source/numem/io/stream/writer.d
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,13 @@ public:
/// Ditto
@trusted
void write(T)(T val) if (isSomeNString!T) {
stream.write(cast(ubyte[])val.toDString());
}

// Size of a single unit
enum S_CHAR_SIZE = T.valueType.sizeof;

// Some char array ptr
auto t = val.adata();
ubyte[] dataToWrite = (cast(ubyte*)t)[0..val.size()*S_CHAR_SIZE];
stream.write(dataToWrite);
/// Ditto
@trusted
void write(T)(T val) if (is(T : string)) {
stream.write(cast(ubyte[])val);
}

/// Ditto
Expand Down

0 comments on commit a875fa4

Please sign in to comment.