Skip to content

fix(profile): improve logging for unsupported code tables#57

Merged
adcondev merged 1 commit intomasterfrom
fix/profile
Nov 6, 2025
Merged

fix(profile): improve logging for unsupported code tables#57
adcondev merged 1 commit intomasterfrom
fix/profile

Conversation

@adcondev
Copy link
Copy Markdown
Owner

@adcondev adcondev commented Nov 6, 2025

Enhance the logging messages for unsupported encoding and code tables to provide clearer context. This change helps in debugging and understanding fallback behavior to Windows-1252.

  • Updated log messages to specify unsupported code tables
  • Ensured proper handling of character code table selection

Descripción

Tipo de cambio

  • 🐛 Bug fix
  • ✨ Nueva funcionalidad
  • 📚 Solo documentación
  • 🔧 Configuración
  • ♻️ Refactoring
  • 📦 Dependencias

¿Cómo se ha probado?

  • Tests automáticos pasan
  • Probado manualmente
  • N/A (solo docs/config)

Checklist

  • El código sigue las convenciones del proyecto
  • Los tests pasan localmente
  • He actualizado la documentación si era necesario

Notas adicionales

This pull request primarily improves the handling of character code tables in the ESC/POS printer service, ensuring unsupported code tables gracefully fall back to Windows-1252 and enhancing warning messages. Additionally, it removes an unused and potentially unsafe file handling utility.

Code table handling improvements:

  • Updated the Initialize and SetCodeTable methods in pkg/service/escpos_registry.go to check if a code table is supported before selecting it, and to explicitly fall back to Windows-1252 with a warning if not. This ensures more robust and predictable printer initialization and configuration. [1] [2]
  • Improved the warning message in EncodeString in pkg/profile/escpos_encoding.go to clarify when an unsupported code table is encountered.

Code cleanup and security:

  • Removed the SafeOpen function and related code from internal/files/files.go, eliminating unused and potentially insecure file handling logic.

Enhance the logging messages for unsupported encoding and code tables
to provide clearer context. This change helps in debugging and
understanding fallback behavior to Windows-1252.

- Updated log messages to specify unsupported code tables
- Ensured proper handling of character code table selection

Signed-off-by: Adrián Constante <ad_con.reload@proton.me>
Copilot AI review requested due to automatic review settings November 6, 2025 20:44
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Nov 6, 2025

👋 Thanks for opening this PR, @adcondev!

Here's what will happen next:

  • 🤖 Automated checks will run
  • 🏷️ Labels will be added automatically
  • 👀 A maintainer will review your changes

Please make sure:

  • ✅ All tests pass
  • 📝 The PR title follows conventional commits
  • 📋 The PR template is filled out completely

@adcondev adcondev moved this to In progress in POS RED2000 Nov 6, 2025
@adcondev adcondev changed the title fix(encoding): improve logging for unsupported code tables fix(profile): improve logging for unsupported code tables Nov 6, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes code table selection logic by ensuring supported code tables are properly validated before use, and removes an unused file security helper.

  • Corrects the Initialize() and SetCodeTable() functions to check for code table support before attempting to use them
  • Improves error message clarity in getEncoding()
  • Removes unused internal/files/files.go package

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.

File Description
pkg/service/escpos_registry.go Fixed logic in Initialize() and SetCodeTable() to properly validate code table support before selection
pkg/profile/escpos_encoding.go Improved warning message clarity to explicitly mention "code table"
internal/files/files.go Removed unused SafeOpen function and files package
Comments suppressed due to low confidence (1)

pkg/service/escpos_registry.go:229

  • When the code table is unsupported and falls back to WPC1252 (line 218), the profile is still updated with the original unsupported codeTable value. This creates an inconsistency where p.Profile.CodeTable doesn't reflect the actually selected code table. Consider updating this line to: p.Profile.CodeTable = character.WPC1252 when falling back, or tracking the actual selected table in a separate variable.
	p.Profile.CodeTable = codeTable

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@adcondev adcondev merged commit b886820 into master Nov 6, 2025
46 of 47 checks passed
@github-project-automation github-project-automation Bot moved this from In progress to Done in POS RED2000 Nov 6, 2025
@adcondev adcondev deleted the fix/profile branch November 6, 2025 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants