I have a C ++ / Cx Windows 8 application and I need to do something similar to the following conversion:
string ^ foo = "32"; Byte Bar = & lt; Foo & gt; Numeric value of How do I change the number stored in a byte type within a string? I am losing without all C # magic which I usually do to get it!
Thanks in advance for any help on this.
You think that looks like C ++ / Cx C #. This is not the case at all, it is pure C ++ with just a few language extensions, which is easy to deal with WinRT types. This platform :: string type is not fair use, it is a general purpose string class not . This is already covered by the standard C ++ library. The class knowingly crippled the disabilities to discourage the experiment. It explains well: When you use methods in Windows Runtime Classes Pass strings forward and backward, or when you are interacting with other Windows runtime components in the application binary, use the Platform :: String Class Interface (ABI) threshold Letfarm :: string class provides methods for many common string operations, but it has not made class a full-featured string. In your C ++ module, use standard C ++ string types such as wstring for any important text processing, and then change the end result before placing the platform :: string ^ with a public interface. It is easy and efficient to convert between wstring or wchar_t * and platform :: string.
Then the appropriate code should be the same:
#include & lt; String & gt; ... std :: wstring foo (L "32"); Auto bar = static_cast & lt; Unsigned four & gt; (Std :: stol (foo));
No comments:
Post a Comment