def _setvalue(value, typ, size, nulls=None, strip=None):
    """Set a field's value"""
    if nulls and value in nulls:
        value = ''
    if strip:
        value = strip.sub('', value)
    if typ == 'N':
        value = str(value).rjust(size, ' ')
    elif typ == 'D':
        try:
            value = value.strftime('%Y%m%d')
        except AttributeError:
            value = ''
    elif typ == 'L':
        value = str(value)[0].upper()
    else:
        value = str(value)[:size].ljust(size, ' ')
    return value
