<commit_before>#ifndef UTILS_MAC_H
#define UTILS_MAC_H

#include "Converters.h"

#include <Foundation/NSString.h>
#include <Foundation/NSAutoreleasePool.h>

#include <QUrl>

// This file can only be #include-d from .mm files

static inline  NSString* fromQBA(const QByteArray& ba) {
    const char* cData = ba.constData();
    return [[NSString alloc] initWithUTF8String:cData];
}

static inline NSURL* fromQUrl(const QUrl& url) {
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    const QByteArray utf8 = url.toEncoded();
    NSURL* nsU = [NSURL URLWithString:fromQBA(utf8)];

    [nsU retain];

    [pool drain];
    return nsU;
}

static inline QUrl toQUrl(NSURL* url) {
    if (!url)
        return QUrl();

    return QUrl(toQString([url absoluteString]));
}<commit_msg>Properly construct QUrl from NSURL when encoded chars are present<commit_after>#ifndef UTILS_MAC_H
#define UTILS_MAC_H

#include "Converters.h"

#include <Foundation/NSString.h>
#include <Foundation/NSAutoreleasePool.h>

#include <QUrl>

// This file can only be #include-d from .mm files

static inline  NSString* fromQBA(const QByteArray& ba) {
    const char* cData = ba.constData();
    return [[NSString alloc] initWithUTF8String:cData];
}

static inline NSURL* fromQUrl(const QUrl& url) {
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    const QByteArray utf8 = url.toEncoded();
    NSURL* nsU = [NSURL URLWithString:fromQBA(utf8)];

    [nsU retain];

    [pool drain];
    return nsU;
}

static inline QUrl toQUrl(NSURL* url) {
    if (!url)
        return QUrl();

    return QUrl::fromEncoded(toQString([url absoluteString]).toUtf8());
}
{'fraction_non_alphanumeric': 0.11867469879518072, 'fraction_numerical': 0.004216867469879518, 'mean_word_length': 4.239747634069401, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2087738', 'n_tokens_mistral': 598, 'n_tokens_neox': 579, 'n_words': 153}