Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read value of type "IBuffer" as string in c#?

Tags:

c#

uwp

How can I copy a variable which is of type IBuffer in C# (UWP app) to a string? The IBuffer itself doesn't seem to have any methods. It has Length which seems to be the correct value. But I cannot see the value in debugger (says requires Native debugging). Below is the class. I need to get Data.

public sealed class MagneticStripeReaderTrackData : IMagneticStripeReaderTrackData
{
    public IBuffer Data { get; }
like image 604
Yasser Asmi Avatar asked May 31 '16 22:05

Yasser Asmi


People also ask

How do you read the content of a file to a string in C?

Steps To Read A File: Open a file using the function fopen() and store the reference of the file in a FILE pointer. Read contents of the file using any of these functions fgetc(), fgets(), fscanf(), or fread(). File close the file using the function fclose().

Is buffer a string in C?

Note that a string is basically an array of chars, terminated by '\0' (NUL). So in this case, buffer is indeed a string. You would want to copy the string only if you want to keep the original and modify the second (or keep a copy of original and then modify buffer).

How do I scan a character string?

You can use the scanf() function to read a string. The scanf() function reads the sequence of characters until it encounters whitespace (space, newline, tab, etc.).

How do I print a string Inc?

using printf() If we want to do a string output in C stored in memory and we want to output it as it is, then we can use the printf() function. This function, like scanf() uses the access specifier %s to output strings. The complete syntax for this method is: printf("%s", char *s);


1 Answers

For example you can use it like this:

var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(Data);
var output = dataReader.ReadString(Data.Length);

You can find same example here. https://msdn.microsoft.com/ru-ru/library/windows/apps/hh464978

like image 193
progpow Avatar answered Oct 07 '22 06:10

progpow