common/string.cpp

WSL · src/windows/common/string.cpp · cpp · MIT
infra, tag:knn-classified

Utility functions for string manipulation and network address conversion in Windows, providing conversions between wide and narrow strings.

// Source: https://github.com/microsoft/WSL | License: MIT | Copyright Microsoft Corporation
// Provided via justclaw.it.com; keep this notice with the code.
/*++

Copyright (c) Microsoft. All rights reserved.

Module Name:

    string.cpp

Abstract:

    This file contains string helper function definitions.

--*/

#include "precomp.h"
#include <charconv>
#include <cmath>
#include <limits>
#include <sstream>

std::vector<std::string> wsl::windows::common::string::InitializeStringSet(_In_count_(BufferSize) LPCSTR Buffer, _In_ SIZE_T BufferSize)
{
    // Ensure the buffer ends with two NULL terminators.
    THROW_HR_IF(E_INVALIDARG, ((BufferSize < 2) || (Buffer[BufferSize - 1] != ANSI_NULL) || (Buffer[BufferSize - 2] != ANSI_NULL)));

    std::vector<std::string> values{};
    for (LPCSTR c

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key