from typing import Counter


def bag_of_character_ngrams(msg, n):
    """
    Extract a bag of character ngrams from a message (including whitespace), with fixed n
    :param msg: input string
    :param n: size of ngram
    :return: bag of features, as a Counter
    """
    if n == 0:
        raise ValueError('n must be a positive integer')
    elif n > len(msg):
        return Counter()
    else:
        return Counter(('char', msg[i:i+n]) for i in range(len(msg)-n+1))