public function convert($dotnetFormat)
    {
        // get string literals and replace with a placeholder to make specifier matching simpler
        $stringLiterals = [];

        $callback = function ($matches) use (&$stringLiterals) {
            $stringLiterals[] = reset($matches);
            return '%s';
        };

        $dotnetFormatPlaceholders = preg_replace_callback(
            $this->getPatternStringLiteralsDotNet(),
            $callback,
            $dotnetFormat
        );

        // match .NET specifiers
        $callback = function ($matches) use ($dotnetFormat) {
            $specifier = reset($matches);

            if (!isset($this->dotnetToPhp[$specifier])) {
                throw new UnsupportedFormatException($dotnetFormat, $specifier);
            }

            return $this->dotnetToPhp[$specifier];
        };

        $phpFormatPlaceholders = preg_replace_callback(
            $this->getPatternSpecifiersDotnet(),
            $callback,
            $dotnetFormatPlaceholders
        );

        // remove slashes from literals
        $callback = function ($value) {
            if ($value == '\\') {
                // don't remove single slashes - these are literal slashes
                return $value;
            }

            // slashes within quotes are literal slashes
            if (preg_match('/^["\'].+["\']$/', $value)) {
                return $value;
            }

            $value = stripslashes($value);

            return $value;
        };

        $stringLiterals = array_map($callback, $stringLiterals);

        // remove quotes from literals
        $stringLiterals = str_replace(['"', '\''], '', $stringLiterals);

        // escape any PHP specifier characters that appear in the string literals
        $callback = function ($matches) {
            $match = reset($matches);
            return '\\' . $match;
        };

        $stringLiterals = preg_replace_callback($this->getPatternSpecifiersPhp(), $callback, $stringLiterals);

        // replace placeholders with string literals
        return vsprintf($phpFormatPlaceholders, $stringLiterals);
    }