MCPcopy Create free account
hub / github.com/OSGeo/gdal / CPLBinaryToHex

Function CPLBinaryToHex

port/cpl_string.cpp:2789–2814  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2787 */
2788
2789char *CPLBinaryToHex(int nBytes, const GByte *pabyData)
2790
2791{
2792 CPLAssert(nBytes >= 0);
2793 char *pszHex = static_cast<char *>(
2794 VSI_MALLOC_VERBOSE(static_cast<size_t>(nBytes) * 2 + 1));
2795 if (!pszHex)
2796 {
2797 pszHex = CPLStrdup("");
2798 return pszHex;
2799 }
2800 pszHex[nBytes * 2] = '\0';
2801
2802 constexpr char achHex[] = "0123456789ABCDEF";
2803
2804 for (size_t i = 0; i < static_cast<size_t>(nBytes); ++i)
2805 {
2806 const int nLow = pabyData[i] & 0x0f;
2807 const int nHigh = (pabyData[i] & 0xf0) >> 4;
2808
2809 pszHex[i * 2] = achHex[nHigh];
2810 pszHex[i * 2 + 1] = achHex[nLow];
2811 }
2812
2813 return pszHex;
2814}
2815
2816/************************************************************************/
2817/* CPLHexToBinary() */

Callers 15

GetFieldAsStringMethod · 0.85
OGRGeometryToHexEWKBFunction · 0.85
AlterGeomFieldDefnMethod · 0.85
ICreateFeatureMethod · 0.85
GetCachedFilenameMethod · 0.85
OpenMethod · 0.85
OGR2SQLITE_ConnectCreateFunction · 0.85
GDALTileIndexInternalFunction · 0.85
DumpReadableMethod · 0.85
SerializeToXMLMethod · 0.85

Calls 1

CPLStrdupFunction · 0.85

Tested by

no test coverage detected