Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

842 B
Raw Blame
export function encodeSpreadsheetTsvCell(value: string | undefined): string {
  if (value === undefined) return "";
  const guarded = guardSpreadsheetFormula(value);
  return /[\t\r\n"]/.test(guarded) ? `"${guarded.replace(/"/g, '""')}"` : guarded;
}

function guardSpreadsheetFormula(value: string): string {
  const candidate = value.replace(/^ +/, "");
  if (candidate.startsWith("-") && isExactSpreadsheetDecimal(candidate.slice(1))) return value;
  if (candidate.startsWith("@") && (candidate.length === 1 || candidate.charCodeAt(1) > 0x7f)) return value;
  return /^[=+\-@\t\r]/.test(candidate) ? `'${value}` : value;
}

function isExactSpreadsheetDecimal(value: string): boolean {
  if (!/^\d+(?:\.\d+)?$/.test(value)) return false;
  const significant = value.replace(".", "").replace(/^0+/, "");
  return significant.length <= 15;
}