Helper functions for Sabre GDS.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mylisp/gds-sabre.el Wed Jun 16 18:38:12 2021 +0300
@@ -0,0 +1,44 @@
+;;;###autoload
+(defun gds-sabre-decode-region (&optional beg end prefix)
+ "Decode garbage coming from UTF8 terminals when Sabre operates in iso-8859-1."
+ (interactive "r\nP")
+ (unless beg (setq beg (region-beginning)))
+ (unless end (setq end (region-end)))
+ (let (text)
+ (setq text
+ (decode-coding-string
+ (encode-coding-string
+ (decode-coding-string
+ (encode-coding-string (buffer-substring beg end) 'iso-8859-1)
+ 'utf-8)
+ 'iso-8859-1)
+ 'cp1252))
+ (when prefix
+ (delete-region beg end)
+ (insert text))
+ text))
+
+;;;###autoload
+(defun gds-sabre-highlight ()
+ (interactive)
+ (highlight-phrase "[[:alpha:]_]*PseudoCityCode=\\|CreationAgent=\\|BookingSource=\\|AgentSine=" 'hi-pink)
+ (highlight-phrase ":Arunk\\|:FlightSegment\\>\\|:FareBasis\\>" 'hi-pink)
+ (highlight-phrase "ResBookDesigCode=\\|Status=\\|FlightNumber=\\|ArrivalDateTime=\\|DepartureDateTime=\\|FareBasisCode=\\|passengerType=\\|isPast=\\|isExpired=\\|itineraryChange=" 'hi-green)
+ (highlight-phrase "InputMessage=" 'hi-blue))
+
+;;;###autoload
+(defun gds-tp-highlight ()
+ (interactive)
+ (highlight-phrase "\\w+Ref=\\|Key=" 'hi-blue)
+ (highlight-phrase "ProviderCode" 'hi-pink)
+ (highlight-phrase "\\w*LocatorCode" 'hi-pink)
+ (highlight-phrase "OwningPCC" 'hi-pink)
+ (highlight-phrase "FareBasis" 'hi-green)
+ (highlight-phrase "CabinClass" 'hi-green)
+ (highlight-phrase "BookingCode" 'hi-green)
+ (highlight-phrase "FareBasis" 'hi-green)
+ (highlight-phrase "ClassOfService" 'hi-green)
+ (highlight-phrase "Status=" 'hi-green)
+ (highlight-phrase "\\w*TotalPrice" 'hi-green))
+
+(provide 'gds-sabre)