Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

std::string to hex

Empfohlene Antworten

Veröffentlicht

Hallo,

ich habe folgendes Problem:

Ich möchte einen std:string in die entsprechende hex-Dastellung

also z.B. 06 F7 ... umwandeln.

Weiteres Problem ist das ich danach noch caste in der Form (BYTE*)a.c_str().

Die Darstellung sollte danach erhalten bleiben.

Habe folgenden Code gefunden, der bis auf dir Formatierung das richtige liefert:

string hexdump( const string& s )

{

stringstream ss;

string::size_type len = s.length();

ss.flags( ios::hex );

for( string::size_type i=0; i<len; ++i ) {

ss << setw(2) << setfill('0') << static_cast<unsigned int>(s);

}

return ss.str();

}

Formatierung war natürlich der falsche Ausdruck.

Habe blöden Fehler gemacht.

Muss mit dem Programm jeweil 2 Registrywerte erstellen.

Der eine ist der Form REG_SZ der andere REG_BINARY.

Falls REG_BINARY gewählt, wird das als Wert einzutragende byte array direkt umgewandelt.

Hatte nur vergessen bei zweiten Wert auch auf REG_BINARY umzustellen.

Das Umwandeln war somit gar nicht nötig, da sonst die hex Darstellung nochmals in hex umgewandelt wird.

Aber vielen Dank für die schnelle Hilfe!

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.